原来从php5.1.0开始,php.ini里加入了date.timezone这个选项,默认情况下是关闭的
也就是显示的时间(无论用什么php命令)都是格林威治标准时间
和我们的时间(北京时间)差了正好8个小时,有以下3中方法可以恢复正常的时间。
1,最简单的方法就是不要用php5.1以上的版本
2,如果一定要用,而且不能修改php.ini,则需要在关于时间的初始化的语句的
上面加上 date_default_timezone_set (XXX);
3,一劳永逸,仅限能修改php.ini。打开php.ini查找date.timezone 去掉前面的分号
= 后面加XXX,重启http服务(如apache2或iis等)即可
关于XXX,大陆内地可用的值是:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次为重庆,上海,乌鲁木齐)
港台地区可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次为澳门,香港,台北)
还有新加坡:Asia/Singapore
老外好像把北京漏调了
其他可用的值是:Etc/GMT-8 ,Singapore ,Hongkong ,PRC
PRC是什么?PRC是中华人民共和国啊-_-
以上都是我从php官方说明档里整理出来的GMT-8下面的地区,可能会有遗漏

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

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

SublimeText3 Mac version
God-level code editing software (SublimeText3)
