How to set time zone errors in php _ PHP Tutorial

Source: Internet
Author: User
How to set the time zone error in php. Php users use the standard time of Lin Weizhi, so it is related to Beijing time for 8 hours. many friends will find a time difference of 8 hours when using phpdate and time, next, let's take a look at the standard time of Lin Weizhi for php users, so it is related to Beijing time for 8 hours. many friends will find a time difference of 8 hours when using php date and time to get the time, next let's look at the solution.

The simplest method is as follows:

The code is as follows:

Date_default_timezone_set ("Etc/GMT + 8"); // This is 8 hours slower than the standard time of Linwei governance

?>

This solves the problem of 8 hours of time difference.

How to set the Beijing Time zone:

The code is as follows:

Date_default_timezone_set ('prc'); // Set the China time zone
?>

The ini_set () function sets the time zone:

Can be added at the beginning of the file

The code is as follows:
Ini_set ('date. timezone ', 'Asia/Shanghai'); // 'Asia/Shanghai'

Shanghai time zone

All of the above are set in the php program, but some time programs are invalid. let's take a look at the operation method in php. ini.

Manually modify php. ini settings

Open php and find

The code is as follows:
Date. timezone = "PRC"

If the semicolon is removed, add it manually!

Returns the time difference of 8 hours when obtaining the latest date and time. let's take a look at it...

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.