Hi, In my project''s config/environments.rb I have set config.time_zone=''UTC''. Whenever a new recorded is added to my mysql database, the "created_at" and "updated_at" fields are stored as UTC.However, on my console the result of Time.now/DateTime.now is in my local timezone, namely IST.>> Time.now=> Wed Nov 03 14:24:55 +0530 2010>> u.created_at=> Wed, 29 Sep 2010 17:50:12 UTC +00:00 How do I change my Time.now/DateTime.now timezone to UTC? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 3 November 2010 08:56, Anjali Thampi <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > > In my project''s config/environments.rb I have set > config.time_zone=''UTC''. > Whenever a new recorded is added to my mysql database, the "created_at" > and "updated_at" fields are stored as UTC.However, on my console the > result of > Time.now/DateTime.now is in my local timezone, namely IST. > >>> Time.now > => Wed Nov 03 14:24:55 +0530 2010Time.now returns the current system time so will be in whatever timezone the system is setup for. You could set the system timezone to UTC but this may not be what you want. Alternatively Time.now.getutc will give the current time in UTC. Colin> >>> u.created_at > => Wed, 29 Sep 2010 17:50:12 UTC +00:00 > > How do I change my Time.now/DateTime.now timezone to UTC? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 3 November 2010 08:56, Anjali Thampi <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> How do I change my Time.now/DateTime.now timezone to UTC?http://railscasts.com/episodes/106-time-zones-in-rails-2-1 http://www.dangarland.co.uk/?p=252 There are lots of other articles online about working with times in Rails. It is a minefield - but that''s not Rails'' fault; it''s that working with times is generally a nightmare ;-) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.