TimeZone time zone setting method in PHP _php tutorial

Source: Internet
Author: User
If you are using a standalone server with permissions to modify the configuration file, setting the time zone can be done by modifying the Date.timezone property in PHP.ini. We can set the value of this property to one of \ "asia/shang\", \ "asia/chongqing\", \ "Etc/gmt-8\" or PRC, etc.

, and then the current time in the PHP script is Beijing time. The configuration file for modifying PHP is as follows:
1.date.timezone = etc/gmt-8
Set the default time zone in the configuration file to East 8 (Beijing time)


Add one more sentence to the PHP program you need:

The code is as follows Copy Code

Date_default_timezone_set (' PRC ');

The test can be written like this:

The code is as follows Copy Code

Date_default_timezone_set (' PRC ');
?>

Whether PHP is installed under Windows or Linux, its default installation time zone is 8 hours from China


You can also open the php.ini file in the server, find the Date.timezone, remove the preceding semicolon, change to date.timezone= PRC (If you cannot find the Date.timezone in php.ini, you can add a line directly DATE.TIMEZONE=PRC also).


Set the time zone in your code

The code is as follows Copy Code
Date_default_timezone_set (' Asia/shanghai ');//' Asia/shanghai ' Asia/Shanghai
Date_default_timezone_set (' asia/chongqing ');//Where asia/chongqing ' is ' Asia/Chongqing '
Date_default_timezone_set (' PRC ');//Where PRC is the "People's Republic of China"

http://www.bkjia.com/PHPjc/632154.html www.bkjia.com true http://www.bkjia.com/PHPjc/632154.html techarticle If you are using a standalone server with permissions to modify the configuration file, setting the time zone can be done by modifying the Date.timezone property in PHP.ini. We can set the value of this property to ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.