PHP 5.x.x 使用date()出现警告问题
2016-09-04 23:23
288 查看
从PHP 5.x.x 开始,当使用date()等函数时,如果timezone设置未指定,在每一次调用时间函数时,都会产生warning信息如下:
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 C:\AppServ\www\demo\01\003\index.php on line 2
2016-09-04:09:03
这是因为没有指定时区造成的(细心观察可以看到打出来的时间也是不对的),我们可以通过warning上说的两种方法进行设置。不过感觉都比较麻烦,最简单的是打开php.ini文件,然后找到“; date.timezone”这一行,然后将其修改为“date.timezone = “Asia/Shanghai””,最后重新启动apache服务即可。
这样我们就永久的指定了时区为上海,不会再报warning了。
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 C:\AppServ\www\demo\01\003\index.php on line 2
2016-09-04:09:03
这是因为没有指定时区造成的(细心观察可以看到打出来的时间也是不对的),我们可以通过warning上说的两种方法进行设置。不过感觉都比较麻烦,最简单的是打开php.ini文件,然后找到“; date.timezone”这一行,然后将其修改为“date.timezone = “Asia/Shanghai””,最后重新启动apache服务即可。
这样我们就永久的指定了时区为上海,不会再报warning了。
相关文章推荐
- 使用PHP的gd库出现问题
- PHP出现mktime()date()时间timezone警告的解决方法,尤其是phpExcelReader会出现这个警告
- 使用gson序列化出现date无法转化问题
- Mac平台解决PhpStorm使用系统默认php解释器出现502的问题
- Windows环境下使用WordPress固定链接出现index.php问题解决方法
- PHP中使用substr()截取字符串出现中文乱码问题该怎么办
- php首次使用date函数 遇到警告:Warning:date():It is not safe to rely on the system's timezone settings.You...
- php date("Y-m-d H:i:s") 出现警告信息
- php使用ZipArchive压缩zip,中文出现乱码问题解决
- discuz 海量信息公司的保10洁 2.1.0使用了短php标签在不支持<?的配置上出现奇怪问题
- php使用date()函数时,提示的警告
- 关与php中session_start()出现警告的问题
- AndroidStudio完美解决"Activity使用Handler时出现警告信息"的问题
- php中使用setcookie出现的问题及解决
- 使用PHP header进行页面跳转出现的问题解疑
- php 中遍历数组时使用引用出现的问题
- 关于使用模态视图时出现警告和报错的问题
- 使用Navicat Premium将Oracle数据库中的表和数据迁移到MySQL数据库中,遇到的Date类型出现精度问题及解决方法
- PHP中,PHP环境搭建,使用WAMPServer出现的问题
- zf2框架的PHP程序,测试环境使用apache,准生产环境使用nginx,出现的问题