PHP Warning: date(): It is not safe to rely on the system
昨天碰到使用date()函数时出现PHP Warning: date(): It is not safe to rely on the system出现这种错误是因为php5默认date.timezone为utc,改为date.timezone = PRC即可.下面看我的方法总结。
在php程序中运行时报如下警告信息:
PHP 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
主要是时区没有设置的缘故,调整很简单,
打开php.ini文件,并找到date.timezone这行,改成如下:
代码如下 | 复制代码 |
date.timezone = Asia/Shanghai |
然后重启apache即可!
在php程序中解决,在你程序前段加上
我们可以在php页面中加入
代码如下 | 复制代码 |
date_default_timezone_set('asia/shanghai'); |
或者
代码如下 | 复制代码 |
ini_set('date.timezone','asiashanghai'); |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor