MySQL returns time with UTC time zone instead of local one

Hey,

I’m trying to write a simple application with Ruby on Rails that works
in my timezone (Prague, UTC + 1). I’ve set my application.rb like this:

#application.rb
config.time_zone = ‘Prague’

and it seems to be working, for example:

Time.now
=> 2011-07-26 13:46:06 +0200 #(+0200 because of the daylight saving
time)

when i try to save the record to the database it workes and stores
itself in the UTC timezone (as it’s supposed to), however, when I try to
load the model from the database, for example:

OpeningHour.first.opening_hour
=> 2000-01-01 05:00:00 UTC

it returns the value in the UTC time zone. Is it supposed to do that?
Every time zone tutorial I’ve stumbled upon so far shows that Rails
should convert the value to the local timezone.

I’m using mysql2 gem and MySQL 5.5 (x64) on Windows 7.

Thanks for any help.

Marek

On Jul 26, 12:52pm, Marek O. [email protected] wrote:

Time.now
=> 2000-01-01 05:00:00 UTC

it returns the value in the UTC time zone. Is it supposed to do that?
Every time zone tutorial I’ve stumbled upon so far shows that Rails
should convert the value to the local timezone.

That looks like a time column rather than a datetime column. I believe
time columns are supposed to just represent a time of day, without
reference to timezone. Apart from anything else, since there is no
associated date you can’t (in general) convert it from UTC to a local
timezone.

Fred

You were right. Thanks a lot, pal.