LoginSignup
1
1

More than 5 years have passed since last update.

RubyOnRailsでのTimezoneの設定

Posted at

を参考に

  • 素のRubyならTimeクラスを使う。
  • RailsならTimeWithZoneクラスを使う。
# currentはapplication.rbのタイムゾーンを使う。戻り値もTimeWithZone。
l Time.current
=> 2014/12/31 10:00:00, EST, ActiveSupport::TimeWithZone

# zone.nowはcurrentと同じ。
l Time.zone.now
=> 2014/12/31 10:00:00, EST, ActiveSupport::TimeWithZone

よりTime.zone.nowを使えばapplication.rbの設定を使ってくれそう
とあるがリファレンスたどって要調査

現在の設定は
* config.time_zone = 'Tokyo'
* config.active_record.default_timezone = 'local' (DBのtimezoneに合わせる)
* DBはJST(Asia/Tokyo)

ってそもそもJSTに寄せようとしているが良いのか。って所も要調査だが。

1
1
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
1
1