1

I have a rails 5 server that is configured to be "Eastern Time (US & Canada)"

The server works great mostly, it stores times in the database in UTC.

For example, if I am in a console and do

 Time.zone.now
 => Fri, 27 Oct 2017 15:07:04 EDT -04:00 

Which is correct (we have not fall back on time yet)

However if I pull down an active record object:

> s = Schedule.first
  Schedule Load (6.2ms)  SELECT  "schedules".* FROM "schedules" ORDER BY "schedules"."id" ASC LIMIT $1  [["LIMIT", 1]]
 => #<Schedule id: 1, product_id: 1, day: "Monday", start_time: "2000-01-01 22:00:00", end_time: "2000-01-01 23:00:00", size: 25, description: "Grades 3-5", created_at: "2017-08-23 14:16:09", updated_at: "2017-08-23 14:16:09", is_full: false> 
2.4.0 :004 > s.start_time
 => Sat, 01 Jan 2000 17:00:00 EST -05:00 

As you can see it convert is to Easter Standard time, which is not correct. Is it possible rails is confused or am I doing something wrong?

(using ruby 2.4)

Joelio
  • 4,621
  • 6
  • 44
  • 80
  • Have you looked at https://stackoverflow.com/questions/6118779/how-to-change-default-timezone-for-active-record-in-rails? There are two config parameters, config.time_zone and config.active_record.default_timezone. What do you have for those values? – John Naegle Oct 27 '17 at 19:36
  • yes, that setting is not in our app, we tried adding it, and it did not help. – Joelio Oct 30 '17 at 15:17

1 Answers1

0

This was user error, the objects date was in EST so Active Record was doing its job, fix was to set it to today and it would be in the right zone.

Joelio
  • 4,621
  • 6
  • 44
  • 80