Convert DateTime String to UTC in rails

后端 未结 3 1399
逝去的感伤
逝去的感伤 2021-01-31 15:29

I have a string like this:

\"2010-01-01 12:30:00\"

I need that to convert to UTC from the current local time zone.

I tried this, but it

3条回答
  •  青春惊慌失措
    2021-01-31 15:58

    For APIs you can use:

    utc_date = Time.parse("2013-05-31 00:00").utc.iso8601 #=> Result will be: 2013-05-30T21:00:00Z
    

    You can check these articles:

    • Working with time zones in Ruby on Rails
    • ISO8601 - Dates In Ruby

提交回复
热议问题