Last active
August 29, 2015 14:17
-
-
Save denisdefreyne/a7d2da49bbba3f4d79e0 to your computer and use it in GitHub Desktop.
Time vs DateTime UTC behavior in Ruby
This file contains hidden or 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
# Ruby’s Time and DateTime classes have different behaviors for #iso8601. Time | |
# uses the "Z" postfix to indicate UTC, while DateTime uses "+00:00". | |
require 'time' | |
require 'date' | |
puts Time.now.utc.iso8601 | |
# => 2015-03-17T08:43:08Z | |
puts Time.now.utc.to_datetime.iso8601 | |
# => 2015-03-17T08:43:08+00:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment