Stijnster
2010-Apr-07 15:58 UTC
rails timezone difference in console and production application
Hi all, I''m on a rails 2.3.5 app. I''ve got my timezone set to ''Brussels''; config.time_zone = ''Brussels'' When I use mysql I see that a date is stored in UTC (as expected); e.g. 2010-04-07 15:03:10 When I use console to print out the date it correctly returns;>> job.created_at.strftime(''%d %b %Y, %H:%M'')=> "07 Apr 2010, 17:03" The Time.zone in console returns "Brussels" with an offset of 3600. However, when I look in my application that same job now has a time of "07 Apr 2010, 18:03". When I print out the Time.zone in a view I get "Athens (UTC +2)", adding an extra hour to the job. We just switched to summer time about a week ago, but I don''t get why the console and webapplication use different Time.zones, while the config.time_zone is defined in both environments. Is someone having the same problems or had the same experience? Stijn -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Geoff B
2010-Apr-07 20:34 UTC
Re: rails timezone difference in console and production application
If you set Time.zone during a request, you override the default value set in config.time_zone for the length of that request. This would explain the difference in Time.zone values between the console and the browser. Can you replicate this issue in a bare 2.3.5 app? If so, please file a bug report with the steps to re-create the issue. Without that,my best guess is that the issue is in your app code. On Apr 7, 10:58 am, Stijnster <s.mathy...@telenet.be> wrote:> Hi all, > > I''m on a rails 2.3.5 app. I''ve got my timezone set to ''Brussels''; > > config.time_zone = ''Brussels'' > > When I use mysql I see that a date is stored in UTC (as expected); > e.g. 2010-04-07 15:03:10 > > When I use console to print out the date it correctly returns; > > >> job.created_at.strftime(''%d %b %Y, %H:%M'') > > => "07 Apr 2010, 17:03" > > The Time.zone in console returns "Brussels" with an offset of 3600. > > However, when I look in my application that same job now has a time of > "07 Apr 2010, 18:03". When I print out the Time.zone in a view I get > "Athens (UTC +2)", adding an extra hour to the job. > > We just switched to summer time about a week ago, but I don''t get why > the console and webapplication use different Time.zones, while the > config.time_zone is defined in both environments. > > Is someone having the same problems or had the same experience? > > Stijn-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Anuj Dutta
2010-Apr-08 08:53 UTC
Re: Re: rails timezone difference in console and production application
On 8 April 2010 02:04, Geoff B <gbuesing@gmail.com> wrote:> > If you set Time.zone during a request, you override the default value > set in config.time_zone for the length of that request. This would > explain the difference in Time.zone values between the console and the > browser. > > Can you replicate this issue in a bare 2.3.5 app? If so, please file a > bug report with the steps to re-create the issue. Without that,my best > guess is that the issue is in your app code. > >This is Rails-core ML, only meant for discussing Rails-core issues. Please refrain from posting it here. Anuj> > On Apr 7, 10:58 am, Stijnster <s.mathy...@telenet.be> wrote: > > Hi all, > > > > I''m on a rails 2.3.5 app. I''ve got my timezone set to ''Brussels''; > > > > config.time_zone = ''Brussels'' > > > > When I use mysql I see that a date is stored in UTC (as expected); > > e.g. 2010-04-07 15:03:10 > > > > When I use console to print out the date it correctly returns; > > > > >> job.created_at.strftime(''%d %b %Y, %H:%M'') > > > > => "07 Apr 2010, 17:03" > > > > The Time.zone in console returns "Brussels" with an offset of 3600. > > > > However, when I look in my application that same job now has a time of > > "07 Apr 2010, 18:03". When I print out the Time.zone in a view I get > > "Athens (UTC +2)", adding an extra hour to the job. > > > > We just switched to summer time about a week ago, but I don''t get why > > the console and webapplication use different Time.zones, while the > > config.time_zone is defined in both environments. > > > > Is someone having the same problems or had the same experience? > > > > Stijn > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > >-- Anuj DUTTA -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Maybe Matching Threads
- Rails 3.0.0.rc // rails locales prevent app boot
- Introduction & time_zone_select with mapped TimeZone question
- Time zone mapping from TimeZone to TZInfo::Timezone
- TimeZone, TZInfo, daylight savings, and composed_of
- Some timezone trouble involving tzinfo and postgresql