添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

想當初剛接觸PHP時,其中遇到的一個問題
在抓取系統時間,使用date()函數時出現以下錯誤:
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 still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.

echo date("H:m:s");

經查詢,是php.ini檔的Date未設定時區

假如不想更改php.ini檔案,但需顯示其餘國家的時間,可以在程式碼內部設定
加入以下程式碼:date_default_timezone_set("Asia/Taipei");
(這邊是以台灣為示範)

經過實做,如下程式碼:

date_default_timezone_set("Asia/Taipei"); echo date("H:m:s");

(參考資料: http://www.w3schools.com/php/php\_date.asp )