0
我可以执行以下操作并获取正确时区中的TimeWithZone对象。使用ActiveSupport :: TimeWithZone指定UTC偏移量而不是时区ActiveSupport :: TimeWithZone
Time.current.in_time_zone('Alaska')
:> Thu, 19 Oct 2017 08:45:08 AKDT -08:00
是否有in_time_zone
等效的方法,我可以通过它在几秒钟的偏移UTC并取回与指定偏移TimeWithZone对象?
offset = -25200 # -25200 seconds == -08:00
Time.current.in_utc_offset(offset)
:> Thu, 19 Oct 2017 08:45:08 -08:00
在此先感谢!
使用Rails 5.1.2
&红宝石2.4.1
正是我一直在寻找,谢谢。我很难在文档中找到它,但却发现了这样的情况。超级有用。 – theartofbeing