Created
September 22, 2008 15:15
-
-
Save queso/12015 to your computer and use it in GitHub Desktop.
Time.now doesn't work for automatic timezone support, but it seems Time.zone.now does. All the documentation indicates that Time.now should work as well...
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
## Anyone care to explain why using Time.now and Time.zone.now result in two different times in the db? | |
>> e = Event.create(:title => "Test2", :url => "http://tests.com", :length => 60, :starts_at => Time.now + 1.day) | |
=> #<Event id: 4, user_id: nil, title: "Test2", url: "http://tests.com", starts_at: "2008-09-23 16:05:14", length: 60, category_id: nil, format_id: nil, advertisment_type: nil, highlight_type: nil, created_at: "2008-09-22 20:05:14", updated_at: "2008-09-22 20:05:14", permalink: "test2", description: nil, popularity: 0.0, promoted: false> | |
>> Time.now + 1.day | |
=> Tue Sep 23 16:05:26 -0400 2008 | |
>> e = Event.create(:title => "Test2", :url => "http://tests.com", :length => 60, :starts_at => Time.zone.now + 1.day) | |
=> #<Event id: 5, user_id: nil, title: "Test2", url: "http://tests.com", starts_at: "2008-09-23 20:05:43", length: 60, category_id: nil, format_id: nil, advertisment_type: nil, highlight_type: nil, created_at: "2008-09-22 20:05:43", updated_at: "2008-09-22 20:05:43", permalink: "test2-2", description: nil, popularity: 0.0, promoted: false> | |
>> Time.zone.now + 1.day | |
=> Tue, 23 Sep 2008 15:06:04 CDT -05:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment