Board logo

標題: [介紹] 設定地區時間date_default_timezone_set() [打印本頁]

作者: plurk    時間: 2010-4-1 23:28     標題: 設定地區時間date_default_timezone_set()

使用 nginx + php-fpm 測試 phpinfo() 時....發現了底下這個warning 訊息...

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

 

查了一下...加上用 date_default_timezone_set()...果然就可以了

引用:

<?php
  date_default_timezone_set("Asia/Taipei");
  echo strftime("%Y-%m-%d %H:%M:%S");
?>


或是直接修改 /etc/php.ini


;date.timezone =

改成

引用:

date.timezone = "Asia/Taipei"


這樣也可以囉 ~~~






歡迎光臨 ADJ網路實驗室 (http://dz.adj.idv.tw/) Powered by Discuz! 6.0.0