Troubleshoot PHP "It is not safe to rely on the system ' s timezone settings" problem, relytimezone_php tutorial

Source: Internet
Author: User
Tags configuration php what php

Fix PHP "It is not safe to rely on the system ' s timezone settings" problem, Relytimezone


If you use more than PHP5.3, the PHP Date function error will appear if you do not have the correct configuration php.ini. Before many old PHP programming tutorials did not mention this problem, so many readers will be confused, the following author for everyone to talk about the three ways to solve this problem.
"PHP Warning:
Date () [Function.date]: It is not safe for rely on the system ' s timezone settings.
You is *required* to use the date.
TimeZone setting or the Date_default_timezone_set () function.
In case you used any of the those methods and you is still getting this warning,
You are most likely misspelled the timezone identifier.
We selected ' UTC ' for ' 8.0/no DST ' instead in '

In fact, from PHP 5.1.0, when a function such as date () is used, if timezone is set incorrectly, E_notice or e_warning information is generated every time the function is called. And in PHP 5.1.0, date.timezone This option, by default, is turned off, no matter what PHP command is Greenwich Mean time, but PHP 5.3 as if there is no setting will be forced to throw the error, to solve this problem, as long as the localization on the line.

First, use Date_default_timezone_set () to set Date_default_timezone_set (' PRC ') on the page header; East Eight time zone echo
Date (' y-m-d h:i:s ');

Second, use Ini_set (' Date.timezone ', ' Asia/shanghai ') in the head of the page;

Third, modify the php.ini (if it is a Windows system, then the file in the C disk, Windows directory, if the system is installed on the C drive). Use Notepad to open php.ini find Date.timezone Remove the previous semicolon modification to become: Date.timezone = PRC
Restart the HTTP service (such as Apache2 or IIS)!

Choose one of the above three methods, and a third method is recommended, so you don't need to add extra code each time.

http://www.bkjia.com/PHPjc/1058148.html www.bkjia.com true http://www.bkjia.com/PHPjc/1058148.html techarticle solve PHP "It is not safe to rely on the system ' s timezone settings" issue, Relytimezone if you use PHP5.3 above, if there is no correct configuration php.ini will appear. ..

  • Related Article

    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.