Possible Duplicate:
UTC time resets to 2000-01-01 (ruby). How do I prevent the time from resetting?
In my application.rb, I have:
config.time_zone = "Eastern Time (US & Canada)"
If, in my application, I display:
<%= Time.now %>
everything looks as I'd expect ("2012-10-09 09:20:39 -0400").
I also have a Session model with an attributes 'start' and 'end' of type Time.
If, in my application code, I create a Session and set s.start=Time.now, the time shows up in the database as a UTC time, which is ok if translated for the application, but with a date of 2000-01-01, and, displays the same way in the application if I have something like:
<%= s.start %>
Also, if I then populate my 'end' attribute some time later with s.end = Time.now, I get a similar 2000-01-01 and UTC time value. At the same time, I set an elapsed time attribute as:
s.elapsed = s.end - s.start
In the database, elapsed shows up as an extremely large number (403056003) even if the difference between start and end is only a few seconds.
If I display s.elapsed and (s.end - s.start) in my application later, s.elapsed shows the big number in the database (obviously), but the calculation of s.end - s.start displays correctly!
Sorry if this is rambling. I'm clearly missing something fundamental, but can't get there.