How can I remove the zone from a DateTime value?

后端 未结 3 795
渐次进展
渐次进展 2021-01-03 18:22

I have this DateTime:

=> Fri, 03 Feb 2012 11:52:42 -0500

How can I remove the zone(-0500) in ruby? I just want something like this:

3条回答
  •  失恋的感觉
    2021-01-03 18:42

    When all else fails

    zoned_time = Time.now
    unzoned_time = Time.new(zoned_time.year, zoned_time.month, zoned_time.day, zoned_time.hour, zoned_time.min, zoned_time.sec, "+00:00")
    

提交回复
热议问题