Skip to content

Instantly share code, notes, and snippets.

@darkskiez
Created October 17, 2013 10:38
Show Gist options
  • Save darkskiez/7022729 to your computer and use it in GitHub Desktop.
Save darkskiez/7022729 to your computer and use it in GitHub Desktop.
ruby time confusion
$ export TZ=MST
$ bundle exec rails c
ruby-1.9.3-p0 :001 > t = Time.new(2013, 1, 1, 0, 0, 0, "+00:00")
=> 2013-01-01 00:00:00 +0000
ruby-1.9.3-p0 :002 > t + 1.day
=> 2013-01-02 00:00:00 -0700
ruby-1.9.3-p0 :003 > t + 1.day.to_i
=> 2013-01-02 00:00:00 +0000
ruby-1.9.3-p0 :004 > 1.day.object_id
=> 172801
ruby-1.9.3-p0 :005 > 1.day.to_i.object_id
=> 172801
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment