Ruby Time.strptime parse
I am trying to parse a datetime with Time class in ruby 2.0. I cant figure
out how to parse date and get it in a specified timezone. I have used
Time.zone.parse to parse a date where I first call Time.zone and set it to
a specified timezone. In the below example, I set the zone but it does not
effect strptime, I have tried doing Time.zone.parse(date) but I cant get
it parse a date like the one below.
Time.zone = "Central Time (US & Canada)"
=> "Central Time (US & Canada)"
irb(main):086:0> Time.strptime("08/26/2013 03:30 PM","%m/%d/%Y %I:%M %p")
=> 2013-08-26 15:30:00 -0400
No comments:
Post a Comment