PHP 关于timezone问题
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.
由于PHP语言中默认设置的是标准的格林威治时间(即采用的是零时区),所以要获取本地当前的时间必须更改PHP语言中的时区设置。更改时间设置有两种方法:
(1)修改php.ini文件中的设置,找到[date]下的 ";date.timezone" 选项,将该项修改为"date.timezone=Asia/Hone_Kong",然后重启apache服务器
(2)在程序中,使用时间/日期函数前添加"date_default_timezone_set("Asia/Hone_Kong");"即可
PHP 关于timezone问题的更多相关文章
- 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 ...
- Date, TimeZone, MongoDB, java中date的时区问题
打印new Date(),Fri Aug 12 13:37:51 CST 2016. 显示Asia/Shanghai的时区,但是date toString 的时区简写却是CST.更坑爹的是,Googl ...
- 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. ...
- mac下apache配置,解决It is not safe to rely on the system's timezone settings.
之前一直转windows平台下做php,很少遇到问题.现在有了macbook,还在慢慢的熟悉中,搭建php开发环境,熟悉mac系统文档组织还有命令,颇费功夫. 今天我在mac下做一个php的练习,用到 ...
- HowTo: Linux Server Change OR Setup The Timezone
Method 1 #tzselect # select timezone e.g. Asia/Shanghai#echo 'Asia/Shanghai' > /etc/timezone # se ...
- PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone
在用PHP5.3以上的PHP版本时,只要是涉及时间的会报一个 Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the ...
- 解决php的“It is not safe to rely on the system’s timezone settings”问题
PHP调试的时候出现了警告: It is not safe to rely on the system解决方法,其实就是时区设置不正确造成的,本文提供了3种方法来解决这个问题. 实 际上,从PHP 5 ...
- java.util.TimeZone 新加方法 getTimeZone(ZoneId zoneId) 导致的问题
最近接受的项目中用spring配置了一个TimeZone对象: <bean id ="timeZone4Job" class="java.util.TimeZone ...
- ubuntu timezone
change timezone sudo dpkg-reconfigure tzdata synchronize time sudo ntpdate time.windows.com
- Lumen 设置 timezone 时区
Lumen 设置 timezone 时区 2015-06-19| wid| 后端开发 今天用 Lumen 框架写代码时, 也是初次体验 Lumen, 遇到了一个问题, 从数据库里查出的时间比数据库里保 ...
随机推荐
- JDBC基础学习(六)—数据库连接池
一.数据库连接池介绍 1.数据库连接池的缘由 对于一个简单的数据库应用,由于对于数据库的访问不是很频繁.这时可以简单地在需要访问数据库时,就新创建一个连接,用完后就关闭它,这样做也不会带来什 ...
- memcached预热失败
缓存逻辑:set和get方法通过中间层SocketServer,由SocketServer去操作缓存(同步备用缓存等) 预热逻辑:在SocketServer里面打日志,通过日志去预热新缓存 出现问题: ...
- Nginx配置同一个域名同时支持http与https两种方式访问
Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的 server{listen 80;listen 443 ssl;ssl on;server_name 域名;in ...
- Windows文件路径转换为java中可识别的文件路径的转义方法,(另附转义多种格式)
ps:欢迎加qq好友:2318645572,交流学习 一:路径转化 Windows中的文件路径格式为 D:\eclipse\apache-tomcat-7.0.67\wtpwebapps\... Ja ...
- lca最近公共祖先(模板)
洛谷上的lca模板题--传送门 学了求lca的tarjan算法(离线),在洛谷上做模板题,结果后三个点超时. 又把询问改成链式前向星,才ok. 这个博客,tarjan分析的很详细. 附代码-- #in ...
- C#小知识点记录,对象的深拷贝
在CSDN中的定义是: public static string CompareExchange( ref string location1, string value, string compara ...
- MarkDown 学习笔记
MarkDown是一种适用于网络的书写语言,可以帮助你快速书写文档,不必再纠结文档排版的问题.并且它的语法简单,学习成本低,程序员必备技能...助你快速书写技术文档.文章. 用于书写 MarkDown ...
- CF IndiaHacks 2016 F Paper task 后缀数组
题目链接:http://codeforces.com/problemset/problem/653/F 大意是给出一个只包含'('和')'的括号串,求有多少不同的子串是合法的括号串 解法:对于每一个后 ...
- CF #93 div1 B. Password KMP/Z
题目链接:http://codeforces.com/problemset/problem/126/B 大意:给一个字符串,问最长的既是前缀又是后缀又是中缀(这里指在内部出现)的子串. 我自己的做法是 ...
- Elasticsearch - 快速入门
Elasticsearch是基于Apache 2.0开源的实时.分布式.分析搜索引擎,相比Lucene,Elasticsearch的上手比较容易,这篇文章主要纪录Elasticsearch的基本概念和 ...