PHP Strict Standards: mktime(): You should be using the time

回覆文章
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

PHP Strict Standards: mktime(): You should be using the time

文章 yehlu »

http://syunguo.blogspot.tw/2013/04/php.html

[PHP]時區設定的錯誤

在PHP上使用內建函數(日期/時間函數)

在PHP5的版本上使用time()、mktime()、date()、gmdate()函數都會出現錯誤訊息




錯誤訊息:

Strict Standards: mktime(): You should be using the time() function instead in C:\xampp\htdocs\Test.php on line 12

解決方式 (建議一跟三的做法)

一、於 PHP 檔案內使用 date_default_timezone_set()

ex:
1
2
3
4
<!--?php
date_default_timezone_set('Asia/Taipei');
echo strtotime('2010-03-01');
?-->


1
2
3
4
5
<span style="font-size: large;">= '5.0.0')
<!--?php
date_default_timezone_set('Asiz/Taipei');
?-->
</span>

二、設定 php.ini
vim /etc/php5/apache2/php.ini # 於 php.ini 的 date.timezone = Europe/Berlin
改成 date.timezone = "Asia/Taipei"

三、設定 php.ini ( Debian 比較建議這樣做, 就不用去分別改 apache / cgi / cli 的 php.ini)
vim /etc/php5/conf.d/date_timezone.ini # 於此檔案加下述
date.timezone = "Asia/Taipei"

在 PHP 5.3.x 這些 ext 的註解已經不建議使用 "#", 所以將這個註解拿掉, 或者將 "#" 改成 ";" 開頭即可. (開頭 ; 也是註解的意思)
回覆文章

回到「PHP」