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(): It is not safe to rely on the system's timezone settings
出现这个错误的原因,主要是因为php.ini里面的时区没有进行设置,可以设置一下,例如:
vi /etc/php.ini
然后找到timezone
将时区设为,例如:Asia/Shanghai
PS: 本来以为通过上述的方式是可以解决问题的,但是经测试,在php5.3版本下,并不能解决问题。
具体操作方式如下:
1、在php配置文件中添加timezone的配置(参照debian的配置规则,添加小的配置规则文件即可,好维护,自定义性好)
~# vim /etc/php/cli-php5.3/ext-active/date_timezone.ini
date.timezone = "Asia/Shanghai"
~ # env-update
~ # source /etc/profile
自定义的文件放在cli-php5.3/ext-active目录中,是因为php默认是采用cli方式,另外ext-active目录是表示启用特性的专用目录,这个可以从/etc/env.d/20php5.3文件中看出来
MANPATH="/usr/lib/php5.3/man/"
CONFIG_PROTECT_MASK="/etc/php/cli-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/apache2-php5.3/ext-active/"
2、在出现错误提示的php文件中添加date_default_timezone_set('Asia/Shanghai');位置是在<?php ?>中
注:
在 某些参考资料中是说这两个方法任选其一就可,但经我测试,必须两个方法同时使用,才不会再出现错误提示。经实测其实第二个方法并不需要在每个出现错误提示 的PHP文件中添加,只需在其中一个PHP文件中添加即可。另外添加的时区不需要与提示中的时区一样,比如系统给我的提示是Chongqing,但我设置 成Shanghai也是一样的,当然这个时间也是与我系统的时区设置是一样的。
http://blog.163.com/litianyichuanqi@126/blog/static/1159794412012815115730262/
php时区设置 warning: strtotime(): It is not safe to rely on the system's timezone settings的更多相关文章
- 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 ...
- 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: 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 ...
- 出现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 ...
- 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 ...
- [服务器时区问题]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: 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 timezon ...
- 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 ...
随机推荐
- <<Joint Deep Modeling of Users and Items Using Reviews for Recommendation>> 评论打分预测
综述: 本文将 CNN 与 FM(Factorization Machine) 结合,基于评论文本来进行评分预测. 简介: 目前将神经网络应用推荐系统的研究工作中,有一类思路是把如CNN等神经网络作为 ...
- C/S模型之UDP协议
说明:利用UDP协议,创建一个服务器和一个客户端.两者间进行通信.由客户端进行输入内容,而服务器将接受的内容进行再一次返回,并显示在服务端. // UDP_Seversock.cpp : 定义控制台应 ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON BitXor
zw版[转发·台湾nvp系列Delphi例程]HALCON BitXor procedure TForm1.Button1Click(Sender: TObject);var image0, imag ...
- 计算概论(A)/基础编程练习2(8题)/3:计算三角形面积
#include<stdio.h> #include<math.h> int main() { // 声明三角形的三个顶点坐标和面积 float x1, y1, x2, y2, ...
- SQL学习之SQL注入总结
Sql注入定义: 就是通过把sql命令插入到web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行的sql命令的目的. sql注入分类: 基于联合查询 基于错误回显 基于盲注,分时间盲 ...
- 20145101《Java程序设计》第9周学习总结
20145101<Java程序设计>第9周学习总结 教材学习内容总结 第十六章 整合数据库 数据库本身是个独立运行的应用程序 撰写应用程序是利用通信协议对数据库进行指令交换,以进行数据的增 ...
- android 实践项目四
android 实践项目四 本周主要是开发android baidumap实现公交的查询 1.权限的取得和对屏幕的支持 <uses-permission android:name="a ...
- C++快速输入输出优化
在这里存一下我的快速输入输出优化 以及写题模板 这里的是$getchar$优化和$putchar$优化,$fread$和$fwrite$暂时咕咕咕 快速输入 这里$define$了一个$I\_int$ ...
- linux中C语言发送广播报文
2. 指令的解决方法: oute add -net 255.255.255.255 netmask 255.255.255.255 dev eth0 metric 1 或者 route add -ho ...
- caffe深度学习网络(.prototxt)在线可视化工具:Netscope Editor
http://ethereon.github.io/netscope/#/editor 网址:http://ethereon.github.io/netscope/#/editor 将.prototx ...