Rails: How to parse date-time string into a specific time zone

前端 未结 7 1228
天命终不由人
天命终不由人 2020-12-01 10:23

I\'m using Rails 3.2 and ruby 1.9.3 on Debian. I have an app that collects a date, time, and timezone in the form of strings via an HTML form. Something like this:



        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 11:00

    Convert specific date format in UTC.

    ActiveSupport::TimeZone['UTC'].parse(Time.strptime('01/24/2019T16:10:16', "%m/%d/%YT%H:%M:%S").asctime)
    

提交回复
热议问题