8小时时差问题对于很多的php程序员来讲不一定全部碰到了,只有使用了自己服务器的朋友可能会碰到了,下面我们来看看php网页时间比实际慢8个小时解决办法
记得刚开始接触php那会,做一个时钟的时候,php网页上返回的时间比实际时间慢8个小时,开始以为自己哪里写错了,检查了好久,最后百度了一下才知道是要配置时区。配置时区不复杂,但是新手往往会被纠结很久。
首先打开PHP安装目录下的“php.ini”文件,然后查找到“date.timezone”这一行,把前面的分号去掉,然后改为“date.timezone=PRC”就可以了。PRC,即中华人民共和国的英语缩写(The People's Republic of China)。最后别忘了重
还有一种情况,如果你不方便修改配置文件,可以直接在你程序的开头加一句
date_default_timezone_set('PRC');就可以了。
也可以在程序中做
date_default_timezone_set('Asia/Shanghai');
echo date('Y-m-d H:i:s');
?>
也可以这样写代码:
date_default_timezone_set('Asia/Chongqing');
echo date('Y-m-d H:i:s');
?>

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

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

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.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools