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

前端 未结 7 1222
天命终不由人
天命终不由人 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:09

    %Z is the correct way to specify a Time zone name. Have you tried the following ?

    date_and_time = '%m-%d-%Y %H:%M:%S %Z'
    DateTime.strptime("04-15-2010 10:00:00 Central Time (US & Canada)",date_and_time)
    
    0 讨论(0)
提交回复
热议问题