Thursday, 15 July 2010

postgresql - 1 hour difference with rails time in postgres prepared statement -



postgresql - 1 hour difference with rails time in postgres prepared statement -

i have problem, doing query in rails converts the wrong time in generated postgres sql statement. time in shell, ruby , postgres 23:32, in generated sql statement 22:32

any ideas whats wrong? utilize rails 3.2.11, pg gem 0.14.1 (installed bundle install)

debian scheme time:

$ date sat feb 9 23:32:10 cet 2013

in ruby:

1.9.2p290 :004 > time.now => 2013-02-09 23:32:15 +0100

in postgres:

=> select current_time; timetz -------------------- 23:32:24.213487+01 (1 row)

generated rails query:

1.9.2p290 :003 > item.where "next_crawling_at < ?", time.now item load (1.1ms) select "items".* "items" (next_crawling_at < '2013-02-09 22:32:17.935595')

looks have set utc time zone in client - though seems contradict result time.now. time.zone?

without additional dst-offset summertime (since have winter now), time zone cet (central european time), while time.now seems translated utc.

you forcefulness particular time zone in ruby time.now.in_time_zone("europe/paris") - (or whatever time zone name fits time zone setting of db).

or can forcefulness utc timestamps time.now.utc , append at time zone 'europe/berlin' in postgres.

or operate timestamp time zone everywhere.

ruby-on-rails postgresql

No comments:

Post a Comment