“date(): It is not safe to rely on the system's timezone settings…”

前端 未结 24 1931
予麋鹿
予麋鹿 2020-11-22 11:06

I got this error when I requested to update the PHP version from 5.2.17 to PHP 5.3.21 on the server.

相关标签:
24条回答
  • 2020-11-22 11:54

    I always keep this line inside codeigniter's root index.php.So that my code works at any server

    date_default_timezone_set('Asia/Dhaka');
    

    List of Supported Timezones here

    0 讨论(0)
  • 2020-11-22 11:54

    In your connection page put a code like this date_default_timezone_set("Africa/Johannesburg"); based on your current location.

    0 讨论(0)
  • 2020-11-22 11:55

    If you using Plesk, try it, First, Open PHP Settings, at the bottom of page, change date.timezone from DEFAULT to UTC.

    0 讨论(0)
  • 2020-11-22 11:57

    Add the following in your index.php file. I first came across this when I moved my application from my XAMPP server to Apache 2.2 and PHP 5.4...

    I would advise you do it in your index.php file instead of the php.ini file.

    if( ! ini_get('date.timezone') )
    {
        date_default_timezone_set('GMT');
    }
    
    0 讨论(0)
  • 2020-11-22 11:57

    You can set the timezone in your .htaccess file

    php_value date.timezone UTC
    
    0 讨论(0)
  • 2020-11-22 11:57

    In addition to setting the date.timezone= as mentioned in several answers, I found an error in the php.ini file that was keeping it from getting to the date.timezone. The way I found it was by running php from the command line in a terminal. this caused an error to be reported at line 114. In my case I had uncommented a setting for displaying errors that had '|' between 2 values. It did not like it. I removed one of the values and the | and everything was good after that

    0 讨论(0)
提交回复
热议问题