I ask these questions because I have a scenario whereby an AR-backed
object, when issued the “published_at” method yields a date like “Tue
Jul 28 17:04:58 UTC 2009”. However, when finding the object, e.g.
Object.first, I get what looks like a UTC date: “2009-07-28 17:07:11”.
(That is, when you find an object in console it shows you all its
attributes, and it is in there that I have what I think is a UTC date.)
I ask these questions because I have a scenario whereby an AR-backed
object, when issued the “published_at” method yields a date like “Tue
Jul 28 17:04:58 UTC 2009”. However, when finding the object, e.g.
Object.first, I get what looks like a UTC date: “2009-07-28 17:07:11”.
(That is, when you find an object in console it shows you all its
attributes, and it is in there that I have what I think is a UTC date.)
Essentially, times recorded in the database by AR are now always in
UTC. The default time_zone is used to convert the DB values from UTC
for local display. The default TZ can be dynamically overridden in
the application to permit individual users to have times displayed in
their own locale TZ.
HTH
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.