LoginSignup
3
2

More than 3 years have passed since last update.

Laravel タイムゾーンを日本に変更する

Posted at

目的

  • タイムゾーン変更の方法をまとめる

実施環境

  • ハードウェア環境
項目 情報
OS macOS Catalina(10.15.3)
ハードウェア MacBook Pro (16-inch ,2019)
プロセッサ 2.6 GHz 6コアIntel Core i7
メモリ 16 GB 2667 MHz DDR4
グラフィックス AMD Radeon Pro 5300M 4 GB Intel UHD Graphics 630 1536 MB
  • ソフトウェア環境
項目 情報 備考
PHP バージョン 7.4.3 Homwbrewを用いて導入
Laravel バージョン 7.0.8 commposerを用いて導入
MySQLバージョン 8.0.19 for osx10.13 on x86_64 Homwbrewを用いて導入

実施方法

  1. 下記コマンドをアプリケーションディレクトリで実行してアプリ設定ファイルを開く。

    $ vi config/app.php
    
  2. 70行目付近に記載されている'timezone' => 'UTC',をコメントアウトする。

  3. コメントアウト直後に下記を追記する。

    アプリ名ディレクトリ/config/app.php
    'timezone' => 'Asia/Tokyo',
    
  4. 82行目付近に記載されている'locale' => 'en',をコメントアウトする。

  5. コメントうと直後に下記を追記する。

    アプリ名ディレクトリ/config/app.php
    'locale' => 'ja',
    
  6. config/app.phpが下記のように修正された事を確認する。

    アプリ名ディレクトリ/config/app.php
    /*
    |--------------------------------------------------------------------------
    | Application Timezone
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
    | ahead and set this to a sensible default for you out of the box.
    |
    */
    
    /*     'timezone' => 'UTC', */
      'timezone' => 'Asia/Tokyo',
    /*
    |--------------------------------------------------------------------------
    | Application Locale Configuration
    |--------------------------------------------------------------------------
    |
    | The application locale determines the default locale that will be used
    | by the translation service provider. You are free to set this value
    | to any of the locales which will be supported by the application.
    |
    */
    
    /*     'locale' => 'en', */
    'locale' => 'ja',
    
3
2
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
3
2