How to set the time zone error in PHP _php tutorial

Source: Internet
Author: User
PHP users are Linwei standard time, so with Beijing time related 8 hours, many friends in the use of PHP Date,time get time will find a difference of 8 hours, the following we look at the solution.

The simplest method is as follows

The code is as follows Copy Code

Date_default_timezone_set ("etc/gmt+8");//This is 8 hours slower than the Linwei standard time.

?>

This solves the problem of 8 hours of jet lag.

How to set the Beijing time zone:

The code is as follows Copy Code

Date_default_timezone_set (' PRC '); Set China time zone
?>

The function Ini_set () Sets the time zone:

Can be added at the beginning of the file

The code is as follows Copy Code
Ini_set (' Date.timezone ', ' Asia/shanghai '); ' Asia/shanghai '

To Shanghai time zone

These are all described in the PHP program to set up, but some time the program is invalid, I came down to see how to operate in the php.ini

To manually modify php.ini settings

Open PHP to find

The code is as follows Copy Code
Date.timezone = "PRC"

If you have to remove the previous semicolon, no words manually added!

http://www.bkjia.com/PHPjc/629122.html www.bkjia.com true http://www.bkjia.com/PHPjc/629122.html techarticle PHP users are Linwei standard time, so with Beijing time related 8 hours, many friends in the use of PHP Date,time get time will find a difference of 8 hours, the following we see ...

  • 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.