LoginSignup
0
0

More than 1 year has passed since last update.

#Ruby で #Rails と同じ Time.zone.now を使う

Last updated at Posted at 2019-11-28
  • activesupportをinstall & require する
  • Time.zone を指定する
  • あとは Rails と同じようにする
gem install activesupport
require 'active_support/core_ext'
# => true

Time.zone
# => nil

Time.zone = 'Tokyo'
# => "Tokyo"

Time.zone
# => #<ActiveSupport::TimeZone:0x00007fded1c02c10 @name="Tokyo", @tzinfo=#<TZInfo::DataTimezone: Asia/Tokyo>, @utc_offset=nil>

Time.zone.now
# => Thu, 28 Nov 2019 17:41:36 JST +09:00

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

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