my time zone is set like this config.time_zone = ''Tokyo'' I got this from console>> temp1.updated_at=> Tue, 06 Oct 2009 13:26:57 JST +09:00>> temp1.updated_at.to_formatted_s(:db)=> "2009-10-06 04:26:57">> temp1.updated_at.to_formatted_s(:long)=> "October 06, 2009 13:26" Can anyone tell me why I get different results when using :db and :long in to_formatted_s?
On Oct 6, 6:05 am, boblu <bobl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> my time zone is set like this > > config.time_zone = ''Tokyo'' > > I got this from console > > >> temp1.updated_at > > => Tue, 06 Oct 2009 13:26:57 JST +09:00>> temp1.updated_at.to_formatted_s(:db) > > => "2009-10-06 04:26:57">> temp1.updated_at.to_formatted_s(:long) > > => "October 06, 2009 13:26" > > Can anyone tell me why I get different results when using :db > and :long in to_formatted_s?Why would you expect them to be the same ? Fred
On Oct 6, 8:57 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 6, 6:05 am, boblu <bobl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > my time zone is set like this > > > config.time_zone = ''Tokyo'' > > > I got this from console > > > >> temp1.updated_at > > > => Tue, 06 Oct 2009 13:26:57 JST +09:00>> temp1.updated_at.to_formatted_s(:db) > > > => "2009-10-06 04:26:57">> temp1.updated_at.to_formatted_s(:long) > > > => "October 06, 2009 13:26" > > > Can anyone tell me why I get different results when using :db > > and :long in to_formatted_s? > > Why would you expect them to be the same ? >Oops, hadn''t noticed that the time of day was different by 9 hours. This is almost certainly because ActiveRecord wants to keep things in the database in UTC. Fred> Fred