PHP显示服务器的当前日期/时间

时间:2014-07-06 21:03:11

标签: php apache freebsd

当我使用这个脚本时:

    <?php
print strftime('%c');
?> 

我得到了

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /usr/local/www/apache22/data/virtual/midterm/boballo.php on line 3
Sun Jul 6 20:41:17 2014

我想要显示的是服务器的当前日期/时间并将其打印到php脚本。我以为服务器(freebsd)会设置时区。如何显示服务器的当前日期并使用php脚本打印?

1 个答案:

答案 0 :(得分:5)

好吧,请阅读错误消息告诉您的内容,最重要的部分:

  

必需使用date.timezone设置或date_default_timezone_set()功能。

做吧!