Home Blog Wiki
Twitter Subscribe to PHP Blog RSS Feed Email RSS
Home > PHP > 时间函数问题-设置PHP5的时区

时间函数问题-设置PHP5的时区

添加评论 三月 17th, 2008
可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明

<?php
$currtime=time();
$currtimestr=strftime ("%H:%M:%S ",$currtime);
echo "The time is : ".$currtimestr;
print (strftime("%A"));
?>

在PHP5中,不能和PHP4一样使用date() , time() 等时间函数正确地取得本地时间, 不同的代码在不同的OS里会产生不同的结果。解决办法,为PHP5设置统一的时区:

编辑 “php.ini”,找到以下行修改:

date.timezone = PRC   //PRC代表中华人民共和国

Your opinion counts (您的意见很重要)