TOP ▲ itcore TOPTIPStimezone.php

PHP タイムゾーンエラーに対処する。| itcore 2017年

# php -v
PHP 5.6.31 (cli) (built: Jul 6 2017 08:06:11)

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. in /var/www/html/test.php on line 4

ini_set( 'display_errors', 1 ); // エラーを画面に出す。
date_default_timezone_set('Asia/Tokyo'); // タイムゾーンの設定 これを設定すればOK
$dt = date("Y-m-d H:i:s");
echo "dt=$dt<br>\n";