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 ...
随机推荐
- python爬虫之解析库正则表达式
上次说到了requests库的获取,然而这只是开始,你获取了网页的源代码,但是这并不是我们的目的,我们的目的是解析链接里面的信息,比如各种属性 @href @class span 抑或是p节点里 ...
- python中@property和property函数使用
1.基本的@property使用,可以把函数当做属性用 class Person(object): @property def get_name(self): print('我叫xxx') def m ...
- C#平均值计算器具体实现
1. 题目及要求 2. Avg.cs 在直接编写窗口程序之前,我们需要创建一个Avg类,我们可以在类库中编辑,也可以像java一样直接在项目中新建类. 有关类库的创建与连接方法,我们在上一次的< ...
- Unity扩展编辑器三
Scene视图是编辑游戏模型的地方,其实它还可以进行编辑,如下图所示,我给Scene视图做了简单的编辑 Scene视图的扩展是基于对象的,意思是你必须在Hierarchy视图中选择一个对象才行,Hie ...
- 【SIKIA计划】_05_Unity5.3开发2D游戏笔记
一.界面基本操作 01.Project基本分类[Audios]音效[Material]材质[Prefabs]预制[Scenes]场景[Scripts]脚本[Sprites]精灵 02.Project丶 ...
- 【LeetCode算法题库】Day3:Reverse Integer & String to Integer (atoi) & Palindrome Number
[Q7] 把数倒过来 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Outpu ...
- Netty源码分析第7章(编码器和写数据)---->第1节: writeAndFlush的事件传播
Netty源码分析第七章: 编码器和写数据 概述: 上一小章我们介绍了解码器, 这一章我们介绍编码器 其实编码器和解码器比较类似, 编码器也是一个handler, 并且属于outbounfHandle ...
- 【视频编解码·学习笔记】12. 图像参数集(PPS)介绍
一.PPS相关概念: 除了序列参数集SPS之外,H.264中另一重要的参数集合为图像参数集Picture Paramater Set(PPS). 通常情况下,PPS类似于SPS,在H.264的裸码流中 ...
- eos源码编译
编译源码 运行代码 在阿里云 纽约服务器上运行没有出现任何问题. 在其他电脑上出现很多问题. 搜集到的问题如下: 随着EOSIO软件越来越成熟,后来的开发者也越来越幸福.EOS相关源码的编译和运行变得 ...
- 忘记本地MySQL数据库密码的解决方案。
忘记本地MySQL数据库密码,解决方案,分以下10个步骤: 参考链接: https://blog.csdn.net/weidong_y/article/details ...