greghauptmann
2010-Feb-26 00:49 UTC
why doesn''t "config.time_zone = ''location''" ensure Time.now gives the time back in this time zone???
Hi, I''m after a way of ensuring all my Time work (e.g. using Time.now) uses the time zone I define as default. To do this I''ve set the following line in config/environment.rb: config.time_zone = ''Brisbane'' But even after this, if I open up "./script/console" I note that Time.now doesn''t work. That is I see: ?> Time.now => Thu Feb 25 16:45:36 -0800 2010 ?> ?> Time.zone.now => Fri, 26 Feb 2010 10:45:33 EST +10:00 >> Is there not a way in rails to ensure any usage of Time.now will give the time in the configured time_zone, i.e. when used in views / controllers / ruby files that are in lib but called from controllers etc? thanks -- 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.
greghauptmann
2010-Feb-26 01:03 UTC
Re: why doesn''t "config.time_zone = ''location''" ensure Time.now gives the time back in this time zone???
think I have it now with: ENV[''TZ''] = ''Australia/Brisbane'' On Feb 26, 10:49 am, greghauptmann <greg.hauptm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m after a way of ensuring all my Time work (e.g. using Time.now) > uses the time zone I define as default. To do this I''ve set the > following line in config/environment.rb: > > config.time_zone = ''Brisbane'' > > But even after this, if I open up "./script/console" I note that > Time.now doesn''t work. That is I see: > > ?> Time.now > => Thu Feb 25 16:45:36 -0800 2010 > ?> > ?> Time.zone.now > => Fri, 26 Feb 2010 10:45:33 EST +10:00 > >> > > Is there not a way in rails to ensure any usage of Time.now will give > the time in the configured time_zone, i.e. when used in views / > controllers / ruby files that are in lib but called from controllers > etc? > > thanks-- 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.