This is pretty confusing for me. My MySQL database server stores times in “SYSTEM”, which is PDT, as does my application server. But I can’t figure out how to make ActiveRecord interpret datetimes coming from my database as already being in PDT format. But if I set:
config.time_zone = "Pacific Time (US & Canada)"
then a database time value of:
2011-06-09 03:19:57
then in the Rails console I end up with:
Wed, 08 Jun 2011 20:19:57 PDT -07:00
It subtracted 7 hours! That tells me it is interpreting the incoming time as UTC instead of Pacific.
So how do I get Rails to interpret database dates in the right time zone?
I found the answer. In environment.rb, I added:
For some reason, it was defaulting to :utc. The docs say it defaults to :utc, but my application wasn’t. Rails 3.0.8 FYI.