date_default_timezone_set('PRC')
Get the time zone and set the time and time zone in the script
Source code:
Date_default_timezone_set('PRC');
echo "China Beijing time :";
echo date("y-m-d h:i:s")."
";
date_default_timezone_set('America/New_York');
echo "New York time:";
echo date("y-m-d h:i:s")
?>
Output:
The two echoes are different and correspond to their respective time zones.
If you cancel date_default_timezone_set(xxx), you can get Beijing time (get both)
The following is how to get China time zone
date_default_timezone_set('Asia/Shanghai');//'Asia/Shanghai' Asia/Shanghai
date_default_timezone_set('Asia/Chongqing');//where Asia/Chongqing' is "Asia/Chongqing"
date_default_timezone_set('Asia/Harbin');//where 'Asia/Harbin' is "Asia/Harbin"
date_default_timezone_set('PRC');//where PRC is "People's Republic of China"
The above introduces php date_default_timezone_set, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.