4

I understand that default behavior of rails is to save the database records and any date/datetime related columns to UTC time. And we can control the display of date/datetime to the users with config.time_zone in environment.rb. So basically config.time_zone setting is to control the display, by which rails converts records from UTC to the one we specify in config.time_zone.

Is there any way or setting to force rails to save the records in EST rather than UTC and still do the conversion to display based on the config.time_zone setting?

-Satynos

Dharam Gollapudi
  • 6,328
  • 2
  • 34
  • 42

2 Answers2

3

You should consider the reasoning behind your question. Remember: Rails implements convention over configuration - and you'd better have a very good reason to want to change the convention! Especially on something as arbitrary as how datetime is saved in the database, and given how easy Rails makes it for us to work with dates.

Trevoke
  • 4,115
  • 1
  • 27
  • 48
0

I don't know about forcing records to be saved in EST, but I wanted to share this discussion about using a local time zone in the db: http://www.ruby-forum.com/topic/890711

From the discussion, I ended up using skip_time_zone_conversion_for_attributes for a similar problem (about that method: http://api.rubyonrails.org/classes/ActiveRecord/Timestamp.html). It may be of interest to you - maybe, set the Time zone to EST, and then try this method.

Good luck! I know it's been a while, but maybe take some time to let people know what you ended up doing.

dmonopoly
  • 3,251
  • 5
  • 34
  • 49