How to set the time zone error in php

Source: Internet
Author: User
Tags php and

The simplest method is as follows:

The code is as follows: Copy code

<? Php

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: Copy code

<? Php
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: Copy code
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: Copy code
Date. timezone = "PRC"

If the semicolon is removed, add it manually!

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.