views:

23

answers:

2

ok this is very strange.

My computers clock is correct, but whenever I output a created_at field in the database and format it, the day/time are off my several hours...

Is there some Rails 3 localhost type setting?

+1  A: 

How is your config.time_zone configured? You can set it to the right timezone in application.rb (Rails3) or environment.rb (Rails") (check http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/).

Yannis
+2  A: 

Rails 3 stores timestamps as UTC in the database. When you pull it out it will format according to config.time_zone in your config/application.rb.

ree-1.8.7-2010.02 > Thing.create
 => #<Thing id: 1, name: nil, created_at: "2010-10-10 17:57:47", updated_at: "2010-10-10 17:57:47"> 
ree-1.8.7-2010.02 > Thing.first.created_at
 => Sun, 10 Oct 2010 13:57:47 EDT -04:00 

Note the difference between created_at in the db and how it is displayed.

Dave Pirotte