plurk 2010-4-1 23:28
設定地區時間date_default_timezone_set()
<p>使用 nginx + php-fpm 測試 phpinfo() 時....發現了底下這個warning 訊息...</p>
<p>Warning: phpinfo(): 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 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /var/www/test.php on line 2 </p>
<p> </p>
<p>查了一下...加上用 date_default_timezone_set()...果然就可以了<br></p>
<p>[quote]<br><?php<br> date_default_timezone_set("Asia/Taipei");<br> echo strftime("%Y-%m-%d %H:%M:%S");<br>?></p>
<p>[/quote]</p><p><br></p><p>或是直接修改 /etc/php.ini</p><p>將 <br></p><p>;date.timezone =<br></p><p>改成</p><p>[quote]</p><p>date.timezone = "Asia/Taipei"<br></p><p>[/quote]</p><p><br></p><p>這樣也可以囉 ~~~<br></p>