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


PHP Show Current Date/Time of Server

当我使用这个脚本时:

    <?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脚本?

好吧,读一下错误信息告诉你的,最重要的部分:

要求使用date.timezone设置或date_default_timezone_set()功能。

做到!