Created
October 4, 2012 04:12
-
-
Save willglynn/3831426 to your computer and use it in GitHub Desktop.
Rails time zones + Date.today + system time zone interaction
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
[1] pry(main)> [`date`, ENV['TZ'], Time.zone, Date.today.midnight, Date.yesterday.midnight] | |
=> ["Wed Oct 3 23:11:03 CDT 2012\n", | |
nil, | |
(GMT+00:00) UTC, | |
Wed, 03 Oct 2012 00:00:00 UTC +00:00, | |
Wed, 03 Oct 2012 00:00:00 UTC +00:00] | |
[2] pry(main)> ENV['TZ'] = 'UTC' | |
=> "UTC" | |
[3] pry(main)> [`date`, ENV['TZ'], Time.zone, Date.today.midnight, Date.yesterday.midnight] | |
=> ["Thu Oct 4 04:11:21 UTC 2012\n", | |
"UTC", | |
(GMT+00:00) UTC, | |
Thu, 04 Oct 2012 00:00:00 UTC +00:00, | |
Wed, 03 Oct 2012 00:00:00 UTC +00:00] | |
[4] pry(main)> ENV['TZ'] = Time.zone = 'US/Central' | |
=> "US/Central" | |
[5] pry(main)> [`date`, ENV['TZ'], Time.zone, Date.today.midnight, Date.yesterday.midnight] | |
=> ["Wed Oct 3 23:11:41 CDT 2012\n", | |
"US/Central", | |
(GMT-06:00) US/Central, | |
Wed, 03 Oct 2012 00:00:00 CDT -05:00, | |
Tue, 02 Oct 2012 00:00:00 CDT -05:00] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created for this Stack Overflow thread.