At first: thats not issue of wrong zone. In irb and database everything is fine. Problem occurs when I want to display dates (created_at, updated_at and all defined by myself in every model) in my views. I was trying to set time zone in application.rb and remove time formats from initializers and that didn’t solved my issue.
schema information generated by Annotate gem:
# created_at :datetime
# updated_at :datetime
# publish_at :datetime
from irb:
1.9.2-p290 :004 > Time.zone
=> (GMT+00:00) UTC
1.9.2-p290 :005 > Time.zone.now
=> Fri, 24 Feb 2012 12:14:04 UTC +00:00
1.9.2-p290 :006 > Time.now
=> 2012-02-24 13:14:07 +0100
Examples:
1.9.2-p290 :007 > Article.last
Article Load (0.3ms) SELECT `articles`.* FROM `articles` ORDER BY `articles`.`id` DESC LIMIT 1
=> #<... created_at: "2012-02-24 12:04:24", updated_at: "2012-02-24 12:04:24", publish_at: "2012-02-24 12:04:24"...>
App displays:
Created_at 2012-02-24 12:02,
Updated_at 2012-02-24 12:02,
Publish_at 2012-02-24 12:02,
1.9.2-p290 :008 > Article.first
Article Load (0.5ms) SELECT `articles`.* FROM `articles` LIMIT 1
=> #<...created_at: "2012-01-30 10:28:07", updated_at: "2012-02-08 17:20:41", publish_at: "2012-02-08 17:20:33"...>
App displays:
Created_at 2012-01-30 10:01,
Updated_at 2012-02-08 17:02,
Publish_at 2012-02-08 17:02
this applies whole app (including active_admin)
Sorry for my English 😉 Any ideas what is the reason of my problem?
I’ve got it 🙂 That was silly, but maybe someone will need reminder: App gets format from locale yml file first (thats only way to set date format in active admin; formats from initializers doesn’t matter):
and ofc minutes in long format should be %M (not %m)