PHP warning date (): Itisnotsafetorelyonthesystem_PHP tutorial

Source: Internet
Author: User
Tags what php
PHP warning date (): Itisnotsafetorelyonthesystem. When PHP versions later than PHP5.3 are used, a Warning: date (): itisnotsafetorelyonthesystemstimezoneset.pdf will be reported if it is time-related. in general, the timezone is not set. When PHP versions later than PHP5.3 are used, a Warning: date () will be reported if the time is involved (): it is not safe to rely on the system \'s timezone settings.

In general, the timezone is not set. in China, the Green + 8 hours are used, so you need to set it.

First

Add the following statement to the page header:

The code is as follows:

Date_default_timezone_set ("PRC"); or ini_set ('date. timezone ', 'asiashanghai ');


This method has the disadvantage that all pages must be added.

Second

Find the date. timezone line in php. ini and change the value to PRC, as shown in figure

The code is as follows:

Date. timezone = PRC.

If you do not have this line, simply add it. Restart the WEB server and PHP.

Friendly reminder: In fact, when using functions such as date () in PHP 5.1.0, if the timezone settings are incorrect, E_NOTICE or E_WARNING information will be generated each time a time function is called. In php5.1.0, date. the timezone option is disabled by default. no matter what php command is used, the Greenwich Mean Time is used. However, it seems that this error will be forcibly thrown out in PHP5.3 if it is not set, to solve this problem, just localize it.

Specified date (): It is not safe to rely on the system \'s timezone settings. It generally means that the timezone is not set ,...

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.