PHP调试的时候出现了警告:

问题:

Warning: phpinfo(): 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. in /mnt/web/index.php on line 2

解决方法1:(最好的方法)在php.ini里加上找到date.timezone项,设置date.timezone = "Asia/Shanghai",重启环境就ok了。
====下面是网上摘抄

It is not safe to rely on the system解决方法,其实就是时区设置不正确造成的,本文提供了3种方法来解决这个问题。

实际上,从PHP 5.1.0开始当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息,而又在php中,date.timezone这个选项,默认情况下是关闭的,无论用什么php命令都是格林威治标准时间,但是PHP5.3中如果没有设置部分时间类函数也会强行抛出了这个错误的。
PS:现在由于大部分人使用VPS/云主机,需要自己配置的环境的就更加会容易出现这个情况。
建议:不熟悉PHP环境还是用比较成熟的一键安装包吧。

方法1:

(最好的方法)在php.ini里加上找到date.timezone项,设置date.timezone = "Asia/Shanghai",重启环境就ok了。

方法2:

在需要用到这些时间函数的时候,在页面添加date_default_timezone_set("PRC");

方法3:

在页头加上设置时区ini_set('date.timezone','Asia/Shanghai');

错误代码:
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

Warning: strtotime(): 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

Warning: date_default_timezone_get(): 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 in <b>/home/ftp/n/nimaboke/include/lib/function.base.php

phpinfo(): It is not safe to rely on the system's timezone settings的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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. ...

  4. mac下apache配置,解决It is not safe to rely on the system's timezone settings.

    之前一直转windows平台下做php,很少遇到问题.现在有了macbook,还在慢慢的熟悉中,搭建php开发环境,熟悉mac系统文档组织还有命令,颇费功夫. 今天我在mac下做一个php的练习,用到 ...

  5. 解决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 ...

  6. 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 ...

  7. It is not safe to rely on the system's timezone settings错误

    在写php程序中有时会出现这样的警告: PHP Warning: date(): It is not safe to rely on the system's timezone settings. Y ...

  8. 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(): ...

  9. date(): It is not safe to rely on the system’s timezone settings.

    在执行php脚本时出现的错误: date(): It is not safe to rely on the system’s timezone settings.You are *required* ...

随机推荐

  1. sql 按天及上午下午分组

    ),r.CTime,), then '下午' end as k, count(*) from Record as r left join Channel as c on r.ChannelId=c.I ...

  2. AtCoder arc078_d Mole and Abandoned Mine

    洛谷题目页面传送门 & AtCoder题目页面传送门 给定一个无向连通带权图\(G=(V,E),|V|=n,|E|=m\)(节点从\(0\)开始编号),要删掉一些边使得节点\(0\)到\(n- ...

  3. Radar Installation(利用数据有序化进行贪心选择)

    English appre: an infinite straight line:一条无限长的直线 on the coasting:在海岸线上 Cartesian coordinate system, ...

  4. Markdown进阶教程

      Markdown是很好用的轻量级标记语言,许多开发人员喜欢使用Markdown来记录学习心得和写博客.本篇博客主要介绍Markdown的高级技巧教程,Markdown的基础教程已经在上篇介绍过了. ...

  5. csrf跨站点请求伪造

    什么是csrf(跨站请求伪造) 伪造请求的定义有很多种,我将不是用户本意发出的请求统称为伪造请求(在用户不知情的情况下执行某些操作)xss的通过用户对浏览器的信任造成的,csrf是通过服务器对浏览器的 ...

  6. Android Studio的第一次运行

    一.开发软件的下载 下载教程 https://blog.csdn.net/bzlj2912009596/article/details/87280191 下载地址 http://www.android ...

  7. ET框架之SceneChangeComponent

    初始化事件 using ETModel; namespace ETHotfix { [Event(EventIdType.InitSceneStart)] public class InitScene ...

  8. JS 抖动函数封装

    原生JS实现封装的抖动函数框架 <style> ul{ margin-top: 100px; } li { float: left; margin-left: 20px; position ...

  9. Python3标准库:textwrap文本自动换行与填充

    1. textwrap文本自动换行与填充 textwrap模块提供了一些快捷函数,以及可以完成所有工作的类TextWrapper.如果你只是要对一两个文本字符串进行自动或填充,快捷函数应该就够用了:否 ...

  10. JavaScript DOM–元素操作

    获取元素 根据 ID 获取元素 语法: document.getElementById(id) <div id='time'>2020-01-09</div> <scri ...