Convert Time from one time zone to another in Rails

前端 未结 5 768
粉色の甜心
粉色の甜心 2020-11-29 17:25

My created_at timestamps are stored in UTC:

>> Annotation.last.created_at
=> Sat, 29 Aug 2009 23:30:09 UTC +00:00

How

5条回答
  •  时光说笑
    2020-11-29 18:22

    If you add this to your /config/application.rb

    config.time_zone = 'Eastern Time (US & Canada)'
    

    Then you can cell

    Annotation.last.created_at.in_time_zone
    

    to get the time in the specified time zone.

提交回复
热议问题