rails time demon in my machine… it eats 2 hours have checked everything!
-
05-07-2019 - |
Question
I have my checked my environment.rb
config.time_zone = 'Prague'
Nothing in development.rb regarding time
This seems to work, in theory...
Time.zone.now # Thu, 10 Sep 2009 17:51:35 CEST +02:00
also correct...
Time.now # Thu Sep 10 17:52:10 +0200 2009
mysql... SELECT NOW() # 2009-09-10 17:53:48
correct!
but when I create a new record in rails or update an old one
Item.create(:price => price, :spots => beds) # 2009-09-10 15:55:28
and have restarted rails many many times!
Solution
It looks like it is saving it in UTC (GMT time), which is two hours earlier than your local time. To a large extent creation times are better stored in UTC --> you then translate them upon viewing.
EDIT: The Timestamp class seems to indicate that the local timestamp is supposed to be used. You may want to check the setting the documentation indicates.
OTHER TIPS
What is the time if you select that record via the console? 15:55 or 17:55?
If you select via the console it uses the timezone that is set, so naturally it will be different from the "real" timestamp in the mysql database.
Take a look at Weird time inconsistencies between production and development as well.