0

I have a model called Order which has a DATETIME (Mysql) column called expiration

I do the following:

order = Order.last

wanted_time = Time.use_zone('Pacific Time (US & Canada)') { Time.now.end_of_day.to_datetime }

And wanted_time gives me: Thu, 20 Nov 2014 23:59:59 -0800

However, when I do:

order.expiration = wanted_time

When I try to fetch order.expiration, I get:

Fri, 21 Nov 2014 07:59:59 UTC +00:00

Why is that? If I specifically have defined the zone I wanted to store it with?

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • did you update order after assigning `wanted_time` value to `order.expiration`. If Yes, can you please add that code also – Choco Nov 21 '14 at 04:56

1 Answers1

0

See this: How to change default timezone for Active Record in Rails?

Change application.rb to have the following lines... I'm guessing theres a difference between rails and db.

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

Community
  • 1
  • 1
williamthomas
  • 105
  • 1
  • 10