Last active
December 14, 2015 06:29
-
-
Save jjb/5043361 to your computer and use it in GitHub Desktop.
There are a few nice guides to timezones in Rails apps (http://www.elabs.se/blog/36-working-with-time-zones-in-ruby-on-rails, http://danilenko.org/2012/7/6/rails_timezones/), but these might be overwhelming if you just want to quickly set and work with a timezone without caring about configuring it app-wide. So, here you go:
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
# First do this | |
Time.zone = 'EST' | |
# Now you can do this | |
Time.zone.now | |
# and this! | |
Time.zone.local(2013, 1, 1) | |
# rails/activerecord/arel work with it: | |
FooBar.where('created_at > ?' Time.zone.local(2012, 1, 1)) | |
# yay! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment