美文网首页
记一个PHP交互模式下的warning

记一个PHP交互模式下的warning

作者: mysimplebook | 来源:发表于2020-08-11 17:30 被阅读0次

PHP调试的时候出现了警告: 

[root@localhost ~]# php -a

Interactive shell

php > $endDate = date('Y-m-d', strtotime("-1 days"));

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in php shell code on line 1

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in php shell code on line 1

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in php shell code on line 1

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in php shell code on line 1

php >

php >

php > date_default_timezone_set('Asia/Shanghai');

php >

php > $endDate = date('Y-m-d', strtotime("-1 days"));

        This warning is repeated every time there is an instance of code containing the strtotime() PHP function.

        To solve it, you must specify a default timezone into the /sites/default/settings.php file. Just add the following line into it:

                    ini_set('date.timezone',date_default_timezone_get());

相关文章

网友评论

      本文标题:记一个PHP交互模式下的warning

      本文链接:https://www.haomeiwen.com/subject/ptssrktx.html