PHP date () and time () are inconsistent with local time _php tutorial

Source: Internet
Author: User
This article introduces PHP date () and time () to obtain a solution that is inconsistent with the local time, the necessary reference solution

Add in the program

Use on page header

The code is as follows Copy Code

Date_default_timezone_set () Set my default time zone to GMT
Date_default_timezone_set (' PRC ');
echo Date (' y-m-d h:i:s ');

The first solution:

Set the default time zone in the program.

The code is as follows Copy Code

Date_default_timezone_set (' PRC '); Set local time zone

Second workaround:

Modify the php.ini to modify the "Date.timezone" entry to "Date.timezone = PRC"

The values available in mainland China are: asia/chongqing, Asia/shanghai, Asia/urumqi (Chongqing, Shanghai, Urumqi, respectively)
Taiwan available: Asia/macao, Asia/hong_kong, Asia/taipei (Macau, Hong Kong, Taipei, respectively)
and Singapore: Asia/singapore
Other available values are: Etc/gmt-8, Singapore, Hongkong, PRC
Note: PRC is the PRC

http://www.bkjia.com/PHPjc/628944.html www.bkjia.com true http://www.bkjia.com/PHPjc/628944.html techarticle This article describes the PHP date () and time () to obtain a solution that is inconsistent with the local time, the need for a reference to the solution in the program to join in the page header using the code as follows copy Generation ...

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