girl 2011-9-20 18:00
CentOS 6.0 下PHP 5.3.x 的 strtotime() 時區設定修正
<P>CentOS 6.0 使用的PHP 已經升級到 5.3.2, 但是在使用時有出現一堆警告訊息. </P>
<P> </P>
<P>我遇到的錯誤訊息: </P>
<P>[quote]</P>
<P>PHP Warning: 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 'Asia/Chongqing' for 'CST/8.0/no DST' instead in ....</P>
<P>[/quote]</P>
<P> </P>
<P><A title="PHP: strtotime - Manual" href="http://php.net/manual/en/function.strtotime.php" target=_blank modo="false"><FONT color=#0066cc>strtotime()</FONT></A> 出現的這個警告是要我們先指定正確的時區(<A title="PHP: List of Supported Timezones - Manual" href="http://www.php.net/manual/en/timezones.php" target=_blank><FONT color=#0066cc>Timezone</FONT></A>), 再來使用這個 function. </P>
<P> </P>
<P>解法方法分享:<BR>設定 php.ini</P>
<P>[quote]</P>
<P>vim /etc/php.ini # 於 php.ini 的 date.timezone<BR>;date.timezone =<BR>改成<BR>date.timezone = "Asia/Taipei" </P>
<P>[/quote]</P>
<P> </P>
<P>Apache 重啟之後...這個訊息就不見啦~~</P>