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
|
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" |
http: //www.bkjia.com/PHPjc/629088.html