LoginSignup
0
0

More than 5 years have passed since last update.

PHPでタイム・ゾーンを設定する

Posted at

こんなエラーが出たら、タイム・ゾーンの設定をしなければいけない。
いわゆる、タイム・ゾーンの設定ができていないということだ。

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. 

設定するには、日付・時刻の関数である
date_default_timezone_setを使う。

date_default_timezone_set('Asia/Tokyo');

PHPではなく設定ファイルで設定するならphp.iniで下記のように設定できる。

date.timezone = "Asia/Tokyo"

Mysqlで日付のカラムを使用する時にPHPでこれらの設定が必要ですね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0