現在時刻がnew DateTime()で取得できない

new DateTime()で停止することがありました。
エラーメッセージは以下の通り。

原文
DateTime::__construct(): 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.

日本語
DateTime :: __ construct():システムのタイムゾーン設定に頼るのは安全ではありません。 date.timezone設定またはdate_default_timezone_set()関数を使用する必要があります。これらの方法のいずれかを使用したにもかかわらずこの警告がまだ表示されている場合は、おそらくタイムゾーン識別子のスペルを間違えたことでしょう。今のところタイムゾーン「UTC」を選択しましたが、あなたのタイムゾーンを選択するためにdate.timezoneを設定してください。

対応
事前にタイムゾーンを指定してやればよいです。
date_default_timezone_set(‘Asia/Tokyo’);

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です