Copyright © 2010 The G String. All Rights Reserved. Snowblind by Themes by bavotasan.com. Powered by WordPress.
I’m currently bug-fixing on a Rails project, and encountered the need to convert the default UTC date-formats into local times, seeing as we’re enjoying our extra hour in our glorious British summer time. The documentation is a little confusing on this point, but I found that a good solution is to keep UTC for use in the database, and to just convert the string representation in the front-end:
<%= some_model.created_at.in_time_zone('London').to_s(:short) %>
This would be good enough to work with sorting, and finds too, provided you were a little careful about which date representation you were using. There is also the ability to change the timezone with Time.zone = “London”.

