Use Time.zone.now instead of Time.now
22 Oct 2014
Using default Ruby
DateTime classes will not show times in the time zone specified by
Time.zone = "Alaska" Time.now Date.today
These show the local time, not the time in Alaska (unless you're already in Alaska).
You should instead use ActiveSupport methods of
Time.zone to pickup the Rails time zone.
This is well-described in The Exhaustive Guide to Rails Time Zones. This should be easy to write a
rails_best_practice rule to implement.
Time zone bugs are particularly tricky when the production server is set to a different time zone (often UTC) than the development machine. Using 'Time.zone` avoids this breakdown of dev/prod parity.