
1、使用“ini_set('date.timezone','PRC')”设置时区。
<?php
header("Content-type:text/html;charset=utf-8");
ini_set('date.timezone','GMT');
echo'当前的格林尼治时间为:'.date('Y-m-dH:i:s',time()).'
';
ini_set('date.timezone','PRC');
echo'国内当前时间为:'.date('Y-m-dH:i:s',time());
?>
2、使用“date_default_timezone_set('PRC')”设置时区。
<?php
header("Content-type:text/html;charset=utf-8");
date_default_timezone_set('Europe/Lisbon');
echo'葡萄牙的当前时间为:'.date('Y-m-dH:i:s',time()).'
';
date_default_timezone_set('PRC');
echo'国内当前时间为:'.date('Y-m-dH:i:s',time());
?>
3、在配置文件中,设置“date.timezone=PRC”。
[Date] ;Definesthedefaulttimezoneusedbythedatefunctions ;http://php.net/date.timezone ;date.timezone=原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END



















































暂无评论内容