Why do these two parse
statements return different results?
time = "13:30:0"
DateTime.parse(time).to_time.utc
#=> 2013-10-13 13:30:00 UTC
Time.parse(time).utc
#=> 2013-10-13 11:30:00 UTC
There is no timezone information in the input String
. DateTime.parse
therefore assumes UTC. Time.parse
assumes local time, and I guess you're in UTC+2.
>> time = "13:30:0"
=> "13:30:0"
>> DateTime.parse(time).to_s
=> "2013-10-13T13:30:00+00:00"
>> Time.parse(time).to_s
=> "2013-10-13 13:30:00 +0200"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With