How do I change the zone offset for a time in Ruby on Rails?

前端 未结 13 2345
感情败类
感情败类 2020-12-30 22:03

I have a variable foo that contains a time, lets say 4pm today, but the zone offset is wrong, i.e. it is in the wrong time zone. How do I change the time zone?

When

相关标签:
13条回答
  • 2020-12-30 22:35

    You can do:

    DateTime.parse('Fri Jun 26 07:00:00 UTC 2009').change(offset: '-0400')
    

    Which returns:

    Fri, 26 Jun 2009 07:00:00 -0400
    
    0 讨论(0)
提交回复
热议问题