Quoting bill walton [email protected]:
happening, but the difference above makes me wonder if there’s a ‘storm
brewing’. Do I need to use one or the other or both ?
The difference is like in Linux/Unix the distinction between the
clock and the system clock. config.active_record.default_time says what
timezone the database stores times. config.timezone says what timezone
server is in.
My laptop uses UTC for the hardware clock and usually Central US for the
system clock. When I am on the West Coast, system time is Pacific US.
file timestamps are actually UTC, but displayed in the local system
With the hardware clock set to the local time, rsyncing between the West
and my server at home would always send the files, because the
never matched. With both systems using UTC hardware clock, that ceased
Back to Rails. I am developing a Rails app on my laptop that is
Amazon’s East Coast data center. The hardware clock on both systems is
UTC. ActiveRecord is set to use UTC for the database. The
set to UTC on the Amazon production server; since users can be anywhere
world, that makes the most sense.
config.timezone for that apps and their users that are just on my laptop
always set to the local time.
You can see the difference in script/console, for a model Item:
[email protected]:~/Rails/amethyst2> script/console
Loading development environment (Rails 2.3.5)
=> Wed Jan 20 12:07:27 -0600 2010
=> Wed, 20 Jan 2010 12:07:29 CST -06:00
item = Item.first
=> #<Item id: 252183, title: “Recycle, Reuse, Reduce”, url:
“http://austinblues.dyndns.org/?p=90”, description: “When we lived in a
house, the recycling bin was jus…”, channel_id: 317, created_at:
“2009-03-16 01:59:15”, synopsis: “Recycle, Reuse, Reduce When we lived
in a house, th…”, dropped_at: nil, updated_at: “2009-12-16 23:29:02”,
ident: “http://austinblues.dyndns.org/?p=90”, time: “Sat, 28 Feb 2009
16:48:44 +0000”, published_at: “2009-02-28 16:48:44”>
=> Sun, 15 Mar 2009 20:59:15 CDT -05:00
=> Mon Mar 16 01:59:15 UTC 2009
Unless the data is never going to be moved (or compared) acros time
would set ActiveRecord to UTC. For the application timezone, look at
users. If they all are in the same timezone, use the local timezone.
makes debugging easier.
It took me a fair number of hours and attempts to understand how
handled and get it correct in all parts of my application. I am clear
the app is aimed at the whole world, so the effort made sense. For an
that I expect to always stay just on my laptop, DB times are in UTC,
laptop moves between timezones, but all times within the app are