views:

63

answers:

1

This one is driving me nuts!! The data is getting stored into the db (sqlite3) correctly. However, when I display the date from the record, Rails appears to coerce it to 1/1/2000 - with the correct time. In other words, if I specify this as the date time: December 31, 2009 6:00 PM, sqllite3 will in fact show 2009-12-31 18:00:00. But.... Rails will display the value has January 1, 2000 06:00 PM (keeping the correct time).

I have created virtual attributes to handle date formatting (which appear to work correctly). And, I have set my time zone to:

config.time_zone = 'Eastern Time (US & Canada)'

I have to believe this is something simple...It is totally driving me nuts!!

Thanks!

John

+1  A: 

Well... I found the problem. As it turned out, when rails created the table, it did so using the Time data type. While the date portion of a datetime value will be stored in a time field, it would appear that when reading a time field, rails only considers the time portion.

The fix.. In desperation, I modified the column to be of datetime type. That fixed it.

John