PHP Warning: strftime(): It is not safe to rely on the system's timezone set
当运行一些程序时,在httpd日志中会有如下警告日志:
PHP Warning: strftime(): 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'。。。。。。。。。。。
原因分析:
这是因为PHP默认是以格林威治标准时间(UTC)为准进行时间转换,因为自己所处的当地时间与UTC会有出入,格林威治标准时间和北京时间有8个小时的时间差。因此我们必须为PHP指定一个时区,让php知道以哪个时区为准进行转换。解决办法:
在你的PHP程序头部使用date_default_timezone_set()设置我的默认时区为北京时间(PRC,中国的英文缩写),即 <?php date_default_timezone_set("PRC"); ?>就可以了。这种方法使用时太复杂,必须在每个使用date的文件中添加相关函数,下面的方法更简单方便。
在php.ini中找到date.timezone行,支持前面的';'号(如果没有修改过的话应该是没有启动此选项的),并将它的值设置为PRC,设置好以后为:date.timezone="Asia/Shanghai"。
PHP Warning: strftime(): It is not safe to rely on the system's timezone set的更多相关文章
- Warning: strftime(): It is not safe to rely on the system's timezone settings.
当运行程序时,会出现如下警告: Warning: strftime(): It is not safe to rely on the system's timezone settings. You a ...
- php : Warning: strftime(): It is not safe to rely on the system's timezone settings.
使用 Smarty 的时候出现这种警告: Warning: strftime(): It is not safe to rely on the system's timezone settings. ...
- [服务器时区问题]PHP Warning: strftime(): It is not safe to rely on the system's timezone set
PHP Warning: strftime(): It is not safe to rely on the system's timezone set 当运行一些程序时,在httpd日志中会有如下警 ...
- PHP Warning: date(): It is not safe to rely on the system's timezone settings.
OSSEC安装结束后运行,运行以下命令却抛错 cat /opt/ossec/logs/alerts/alerts.log 具体抛错内容: ** Alert 1468897672.2164786: ma ...
- PHP Warning: phpinfo(): It is not safe to rely on the system's timezone setting
错误描述: PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *re ...
- php时区设置 warning: strtotime(): It is not safe to rely on the system's timezone settings
warning: strtotime(): It is not safe to rely on the system's timezone settings warning: strtotime(): ...
- Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use ...报错
错误截图 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* t ...
- 出现Warning: date(): It is not safe to rely on the system's timezone settings的解决办法
在没有配置,尤其是新安装的PHP中使用date函数时,会报这个错误: Warning: date(): It is not safe to rely on the system's timezone ...
- PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings.
有三种解决办法: 1. php文件中设置时区 <?php date_default_timezone_set('Asia/Shanghai'); echo strtotime('2012-9-3 ...
随机推荐
- Codewars笔记
说明:以下内容均来自codewars网站,列举的试题我都做过且通过,并以此记录来学习python. 1,需求:将大小写互相转换,非字母的字符保留 我的代码: def to_alternating_ ...
- Selenium+Python自动化测试学习问题总结笔记
1.问题描述:不能导入自定义类 错误内容:This inspection detects names that should resolve but don't. Due to dynamic dis ...
- CentOS安装GoAccess
官网 https://goaccess.io/ yum -y install glib2 glib2-devel ncurses ncurses-devel GeoIP GeoIP-devel安装依赖 ...
- [ 转]Shell中参数($0,$1,$#,$NF,$@等)的含义
Shell中参数($0,$1,$#,$NF,$@等)的含义 发布时间:2018-01-19 来源:网络 上传者:用户 摘要:此处仅仅从来记录平时常用的命令的参数.以免下次忘记时及时找到.也方便更多的人 ...
- JUC——线程同步辅助工具类(Semaphore,CountDownLatch,CyclicBarrier)
锁的机制从整体的运行转态来讲核心就是:阻塞,解除阻塞,但是如果仅仅是这点功能,那么JUC并不能称为一个优秀的线程开发框架,然而是因为在juc里面提供了大量方便的同步工具辅助类. Semaphore信号 ...
- [操作系统]makefile
makefile文件保存了编译器和连接器的参数选项,还表述了所有源文件之间的关系(源代码文件需要的特定的包含文件,可执行文件要求包含的目标文件模块及库等). 创建程序(make程序)首先读取makef ...
- Ubuntu下配置Anaconda
转自:https://blog.csdn.net/Horcham/article/details/57075388 安装Anaconda Ubuntu下似乎库中不自带Anaconda,是自带纯净的py ...
- Kettle日常使用汇总整理
Kettle日常使用汇总整理 Kettle源码下载地址: https://github.com/pentaho/pentaho-kettle Kettle软件下载地址: https://sourcef ...
- linux-shell-screen后台调用-后台运行脚本和命令-仿start命令-伪窗口界面
序 我比较熟练bat.cmd脚本.刚接触使用shell时,总会习惯想用windows窗口界面来套用shell脚本.于是找到screen后台命令,它可以交互shell脚本,保持后台运行.但是在批处理ba ...
- 切换nPar或vPar的启动模式
在EFI Shell中执行vparconfig即可随意切换vpar和npar模式 该命令在\EFI\HPUX目录下 vparconfig 显示当前的模式 vparconfig reboo ...