I’ve developed a rails application locally (Denmark), and have now
uploaded it to my server, witch is located in the US.
What didn’t come to my attention in the development face was the
difference in time zones.
I’v tried setting the “default_timezone”-tag i environment.rb, but the
time it still rendered wrong.
The least confusing approach, in my opinion, is to use UTC everywhere.
I assume you mean you have set the default timezone in environment.rb
Consequently, when storing times in the database, you should use
Time.now.utc instead of Time.now.
When displaying times in your views, use a helper to convert from UTC
to the user’s local time zone.
I sympathise with your frustration. Time zones can be fiddly but,
once everything is configured correctly, you can forget about them
(until you deploy your next app on new servers when you won’t be able
to remember quite what you did the previous time to get it all
If you’ve set Rails up to use UTC and you’re still having trouble,
it’s worth checking that your app server and database server have
their system clocks and timezones set correctly… That’s caught me
out in the past and it was infuriating.