Created
October 31, 2012 14:11
-
-
Save weidenfreak/3987229 to your computer and use it in GitHub Desktop.
DateTime in Rails is missing milliseconds after substracting 1 day, Time is not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ irb | |
>> DateTime.now | |
=> #<DateTime: 2012-10-29T16:00:33+01:00 ((2456230j,54033s,774400000n),+3600s,2299161j)> | |
>> DateTime.now - 1 | |
=> #<DateTime: 2012-10-28T16:00:37+01:00 ((2456229j,54037s,137431000n),+3600s,2299161j)> | |
$ rails c | |
>> DateTime.now.iso8601 9 | |
=> "2012-10-29T16:03:17.237282000+01:00" | |
>> (DateTime.now - 1.day).iso8601 9 | |
=> "2012-10-28T16:03:21.000000000+01:00" | |
>> Time.now.iso8601 9 | |
=> "2012-10-29T16:03:59.672321000+01:00" | |
>> (Time.now - 1.day).iso8601 9 | |
=> "2012-10-28T16:04:08.504329000+01:00" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment