ruby on rails - MYSQL wrong time.now -


we got rails 3 server based on ruby 1.9.2 running on mysql db , problems time.now , time.zone.now setting.

for better explaination assuse 13:00 utc right now.

  • ubuntu systemtime set 15:00 utc +02:00 (thats cest (central european summertime) , correct our timezone).

  • the rails time (time.now) set 13:00 +0200

  • the time.zone.now set cest
  • mysql global time , session time both set system

now create new entry in mysql db (via activerecord) has timestamp.

but when @ timestemp -2 hours offset current server time (in our example 11:00)

we tried setting time.zone different 1 testing propose, had absolutly no effect on new mysql entry. tried set mysql global time , session time utc, no effect.

the thing can imagene right problem time.now taking effect on mysql entry , set wrong. problem here: we're unable set time.now setting. if possible somehow (is it?), dunno if fixes problem.

did ever have such problem or ideas cause it?

there 2 things configure rails.

  1. the current timezone you've done (used in time.zone.now), sets timezone timestamps in instantiated records load.

  2. the timezone values converted when stored db. should set same timezone system/mysql. think option configured via: activerecord::base.default_timezone = :utc

since system time set cest, you'll want use same value well.

the reason there 2 config options incase you've got users in multiple timezones (international audience), time.zone can set differently each logged in user, , db timezone convert correctly time.zone timezone.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -