Home  >  Article  >  Backend Development  >  How to set time zone error in php_PHP tutorial

How to set time zone error in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:13:38846browse

PHP users use Linwich Standard Time, so it is 8 hours related to Beijing time. Many friends will find that there is an 8-hour time difference when using php date and time to obtain the time. Let’s look at the solution below.

The simplest way is as follows

The code is as follows
 代码如下 复制代码

date_default_timezone_set("Etc/GMT+8");//这里比林威治标准时间慢8小时

?>

Copy code

代码如下 复制代码

date_default_timezone_set('PRC'); //设置中国时区
?>

date_default_timezone_set("Etc/GMT+8");//This is 8 hours behind London Standard Time

?>

 代码如下 复制代码
ini_set('date.timezone','Asia/Shanghai'); // 'Asia/Shanghai'

This solves the problem of 8 hours time difference

How to set Beijing time zone:

The code is as follows Copy code

 代码如下 复制代码
date.timezone = "PRC"
date_default_timezone_set('PRC'); //Set China time zone
?>

Function ini_set() sets the time zone:

You can add

at the beginning of the file is Shanghai time zone The above description is all set in the php program, but sometimes it is invalid in the program. Let me come down and see how to operate it in php.ini Manually modify php.ini settings Open php and find If necessary, remove the semicolon in front, if not, add it manually!
http://www.bkjia.com/PHPjc/629122.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629122.htmlTechArticlephp users are using Linwich Standard Time, so it is related to Beijing time for 8 hours. Many friends are using php date , when you get the time, you will find that there is an 8-hour time difference. Let’s take a look...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn