2011-03-21

Xampp中php的 timezone 設定

Xampp中的php.ini,[Date]中的date.timezone沒有給預設值
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667

; http://php.net/date.default-longitude
;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333

所以部分的程式再執行的時候,會出現如下的Warning
Warning: strftime() [function.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 'UTC' for '8.0/no DST' instead in C:\xampp\htdocs\Smarty307\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 59

避免這個Warning警告訊息的作法:

  1. 在php.ini的[Date]中加入:date.timezone="Asia/Taipei"
  2. 或在程式中加入 date_default_timezone_set("Asia/Taipei")

沒有留言:

張貼留言