note: PHP 時區問題

2012101909:08

php 5.3 以後要設定 php.ini 中的時區資料
否則一堆錯誤訊息:


$ php test.php

PHP Warning:  date(): 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 s
till getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'C
ST/8.0/no DST' instead in /home/user/test.php on line 4
 

php.ini 中設定
[Date]
date.timezone = "Asia/Taipei"

或是 php 程式最前方加上:
<?php

  date_default_timezone_set("Asia/Taipei");
 
//  or
  ini_set('date.timezone','Asia/Taipei');

...

?>