PHPDate () specific solution to errors _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Specific solutions for PHPDate () errors. When obtaining system time, we find that the obtained time is inconsistent with the system time. Today, when we use echodate (Y-m-dH: I: s) to obtain the system time, we find that the obtained time and system time are being used.

When obtaining the system time, it is found that the obtained time is inconsistent with the system time. Today, when we use echo date ("Y-m-d H: I: s") to obtain the system time, we find that the obtained time is inconsistent with the system time.

PHP is developed by foreigners, so many things are often difficult to use. After some research, we found that the default time set by PHP is based on Greenwich Mean Time Zone, which is eight hours time difference from Beijing. Therefore, we need to add 8 hours to it, the principle is that we are located in the East 8 zone of the time zone, so we must change the time zone of PHP to Beijing time.

Specific solutions for PHP Date () errors:

Open the PHP. ini file, usually in the PHP installation root directory
Find the; date. timezone
Delete The Semicolon before date. timezone and change it to date. timezone = PRC.
Save the disk and restart the Apahce service (sometimes there is a problem with the Apache restart function. we recommend that you stop and start again)
Verify echo date ("Y-m-d H: I: s") again ").
Is the time back to normal?

If you cannot change the PHP. ini file, you can also use date_default_timezone_set () to set the time zone before the output time.

Date_default_timezone_set ('Asia/Shanghai ');

Functions date_default_timezone_set (timezone) and date_default_timezone_get ()

The above are the solutions for PHP Date () errors.


When the token obtains the system time, it is found that the obtained time is inconsistent with the system time. Today, when we use echo date (Y-m-d H: I: s) to obtain the system time, we find the obtained time and system time...

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.