LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > 脚本编程 >

处理PHP函数中使用date命令时的Warning

时间:2015-01-19 09:44来源:未知 编辑:linuxeye 点击:
在PHP代码中调用date函数时,在日志里看到如下报错 PHP 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() func

在PHP代码中调用date函数时,在日志里看到如下报错

PHP 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 'Asia/Chongqing' for 'CST/8.0/no DST' instead

为什么会出现这样的报错?

处理方法1
在调用date前加入下代码

ini_set('date.timezone','Asia/Shanghai');

转载请保留固定链接: https://linuxeye.com/program/2107.html

------分隔线----------------------------
标签:php
栏目列表
推荐内容