views:

73

answers:

2

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!

+1  A: 

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.

Kathy Van Stone
I tried putting 'UTC+2', 'UTC +02:00' but when loading rails via console it gave me errors.
holden
Your local timezone is UTC + 2 -- see my edits
Kathy Van Stone
A: 

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 http://stackoverflow.com/questions/1416294/weird-time-inconsistencies-between-production-and-development/1426961 as well.

Bitterzoet