TShopping

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

作者: woff    時間: 2010-6-8 12:16
標題: 設定地區時間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");
?>





歡迎光臨 TShopping (http://www.tshopping.com.tw/) Powered by Discuz! X3.2