Home > Backend Development > PHP Tutorial > date_default_timezone_set method to set China time zone_PHP tutorial

date_default_timezone_set method to set China time zone_PHP tutorial

WBOY
Release: 2016-07-13 17:13:48
Original
1108 people have browsed it

The following introduces the method of date_default_timezone_set to set the Chinese time zone. The function is simple and easy to use, and friends in need can refer to it.

date_default_timezone_set — Set the default timezone used for all datetime functions in a script.


Grammar

bool date_default_timezone_set ( string $timezone_identifier )


Parameter Description
timezone Required. Time zone identifier, such as "UTC" or "Europe/Paris".


Description
Note: Since PHP 5.1.0 (the date and time functions have been rewritten in this version), if the time zone is illegal, each call to the date and time function will generate an E_NOTICE level error message if the system setting or TZ environment variable is used. E_STRICT level information will also be generated.

Set China time zone

The code is as follows
 代码如下 复制代码
date_default_timezone_set('Asia/Shanghai');//'Asia/Shanghai' 亚洲/上海
date_default_timezone_set('Asia/Chongqing');//其中Asia/Chongqing'为“亚洲/重庆”
date_default_timezone_set('PRC');//其中PRC为“中华人民共和国”
Copy code


date_default_timezone_set('Asia/Shanghai');/ /'Asia/Shanghai' Asia/Shanghai date_default_timezone_set('Asia/Chongqing');//Asia/Chongqing' is "Asia/Chongqing"

date_default_timezone_set('PRC');//where PRC is "People's Republic of China"

Note: Any of the above 3 methods can meet our needs.

http://www.bkjia.com/PHPjc/629088.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/629088.html
TechArticle
The following will introduce the date_default_timezone_set method of setting the Chinese time zone. The function is simple and easy to use. Friends in need can refer to it. The date_default_timezone_set setting is used for everything in a script...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template