Hello, I need to ask this to the list because I am not getting answers on the IRC channel... I have a PGSQL DB where I have some columns defined as "timestamp". When I display the object.posted_on on Rails, it shows: Posted On Sat Jan 01 23:24:30 EST 2000 When the DB record has: 2004-12-09 23:24:30.957275 I have tried "timestamp with time zone" but that doesn''t change this behavior. Even when I store Time.now on the column from my Rails application, I still get this "Jan 01 2000" instead of the proper date time. Using the latest gems beta of Rails (getting it from gems.rubyonrails.org) / PostgreSQL 7.4.2 / ruby-postgresql 0.7.1 on Mac OS X 10.3.6 Any ideas? I am not sure if this has always been the case since I was too new to Rails to even get anything to display ... Now I have a full CRUD setup but I am getting this ... Thanks in advance for any help/ideas. /B -- Bruno Mattarollo <bmatt-ee4meeAH724@public.gmane.org> Currently in: Sydney, Australia [ http://pokies.typepad.com/virtual_possum/ ] _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Actually this went as a fix recently for the time data type in MySQL which contains only time and no date. The equivalent MySQL data type is datetime. Maybe something similar exists in Postgres. You will need to use that. --Shyam On Thu, 9 Dec 2004 23:29:41 +1100, Bruno Mattarollo <bmatt-ee4meeAH724@public.gmane.org> wrote:> Hello, > > I need to ask this to the list because I am not getting answers on the > IRC channel... I have a PGSQL DB where I have some columns defined as > "timestamp". When I display the object.posted_on on Rails, it shows: > > Posted On Sat Jan 01 23:24:30 EST 2000 > > When the DB record has: 2004-12-09 23:24:30.957275 > > I have tried "timestamp with time zone" but that doesn''t change this > behavior. Even when I store Time.now on the column from my Rails > application, I still get this "Jan 01 2000" instead of the proper date > time. > > Using the latest gems beta of Rails (getting it from > gems.rubyonrails.org) / PostgreSQL 7.4.2 / ruby-postgresql 0.7.1 on Mac > OS X 10.3.6 > > Any ideas? > > I am not sure if this has always been the case since I was too new to > Rails to even get anything to display ... Now I have a full CRUD setup > but I am getting this ... > > Thanks in advance for any help/ideas. > > /B > > -- > Bruno Mattarollo <bmatt-ee4meeAH724@public.gmane.org> > Currently in: Sydney, Australia > [ http://pokies.typepad.com/virtual_possum/ ] > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-- "The best way to predict the future is to invent it" -- Alan Kay
On Thu, 9 Dec 2004, Shyam Gopale wrote:> Actually this went as a fix recently for the time data type in MySQL > which contains only time and no date.A "timestamp" in PostgreSQL includes both date and time information. This is nothing at all like MySQL''s "timestamp." cjs -- Curt Sampson <cjs-gHs2Wiolu3leoWH0uzbU5w@public.gmane.org +81 90 7737 2974 http://www.NetBSD.org Make up enjoying your city life...produced by BIC CAMERA
On Thu, Dec 09, 2004 at 11:29:41PM +1100, Bruno Mattarollo wrote:> Hello, > > I need to ask this to the list because I am not getting answers on the > IRC channel... I have a PGSQL DB where I have some columns defined as > "timestamp". When I display the object.posted_on on Rails, it shows: > > Posted On Sat Jan 01 23:24:30 EST 2000This is from ruby''s Time class. PostgreSQL''s timestamps are converted to Time objects in AR. You can use Time#strftime to format timestamps pulled from the DB.> When the DB record has: 2004-12-09 23:24:30.957275This is how postgresql displays them, it''s just different from Time''s #to_s.> I have tried "timestamp with time zone" but that doesn''t change this > behavior. Even when I store Time.now on the column from my Rails > application, I still get this "Jan 01 2000" instead of the proper date > time.I''m not quite understanding this. Are you saying that putting Time.now into a timestamp column then yields only the date portion? -Scott
On 10/12/2004, at 12:28 AM, Scott Barron wrote:>> I have tried "timestamp with time zone" but that doesn''t change this >> behavior. Even when I store Time.now on the column from my Rails >> application, I still get this "Jan 01 2000" instead of the proper date >> time. > > I''m not quite understanding this. Are you saying that putting Time.now > into a timestamp column then yields only the date portion?No, sorry ... I wasn''t clear ... When I do an insert into a field with "timestamp" and I insert "now()" for example, I get something like: 2004-12-09 23:24:30.951274 In that field ... but when I save my object and in that field I put Time.now and then so a select from that field in psql I get: 2000-01-01 23:30:52 (Note year 2000 ... etc) and when I update it I get: 2004-12-09 23:32:03 Still renders are Jan 01 2000 23:32:03 though in the web browser ... It''s very strange indeed ... it''s 1AM now so I am going to get some sleep but I am puzzled /B -- Bruno Mattarollo <bmatt-ee4meeAH724@public.gmane.org> Currently in: Sydney, Australia [ http://pokies.typepad.com/virtual_possum/ ] _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Bruno Mattarollo wrote:> > On 10/12/2004, at 12:28 AM, Scott Barron wrote: > >>> I have tried "timestamp with time zone" but that doesn''t change this >>> behavior. Even when I store Time.now on the column from my Rails >>> application, I still get this "Jan 01 2000" instead of the proper date >>> time. >> >> >> I''m not quite understanding this. Are you saying that putting Time.now >> into a timestamp column then yields only the date portion? > > > No, sorry ... I wasn''t clear ... When I do an insert into a field with > "timestamp" and I insert "now()" for example, I get something like: > > 2004-12-09 23:24:30.951274 > > In that field ... but when I save my object and in that field I put > Time.now and then so a select from that field in psql I get: > > 2000-01-01 23:30:52 > > (Note year 2000 ... etc) and when I update it I get: > > 2004-12-09 23:32:03 > > Still renders are Jan 01 2000 23:32:03 though in the web browser ... > It''s very strange indeed ... it''s 1AM now so I am going to get some > sleep but I am puzzled > > /B > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/railsI believe I''m at fault here :( I submitted the patch that handles the TIME field in MySQL, but I didn''t take TIMESTAMP into account. I''ll post a patch to the Trac today. -- Jorgen Hahn www.niveon.com
> I believe I''m at fault here :( I submitted the patch that handles the > TIME field in MySQL, but I didn''t take TIMESTAMP into account. I''ll > post a patch to the Trac today.It has been applied and new beta gems have been uploaded. -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain
Jorgen Hahn wrote:> Bruno Mattarollo wrote: > >> >> On 10/12/2004, at 12:28 AM, Scott Barron wrote: >> >>>> I have tried "timestamp with time zone" but that doesn''t change this >>>> behavior. Even when I store Time.now on the column from my Rails >>>> application, I still get this "Jan 01 2000" instead of the proper date >>>> time. >>> >>> >>> >>> I''m not quite understanding this. Are you saying that putting Time.now >>> into a timestamp column then yields only the date portion? >> >> >> >> No, sorry ... I wasn''t clear ... When I do an insert into a field with >> "timestamp" and I insert "now()" for example, I get something like: >> >> 2004-12-09 23:24:30.951274 >> >> In that field ... but when I save my object and in that field I put >> Time.now and then so a select from that field in psql I get: >> >> 2000-01-01 23:30:52 >> >> (Note year 2000 ... etc) and when I update it I get: >> >> 2004-12-09 23:32:03 >> >> Still renders are Jan 01 2000 23:32:03 though in the web browser ... >> It''s very strange indeed ... it''s 1AM now so I am going to get some >> sleep but I am puzzled >> >> /B >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > I believe I''m at fault here :( I submitted the patch that handles the > TIME field in MySQL, but I didn''t take TIMESTAMP into account. I''ll post > a patch to the Trac today. >Patch has been submitted and applied. You should see the proper behavior in the next beta gems :) -- Jorgen Hahn www.niveon.com
On 10/12/2004, at 2:58 AM, Jorgen Hahn wrote:> Patch has been submitted and applied. You should see the proper > behavior in the next beta gems :)Thanks, I am seeing proper dates now. Cheers /B -- Bruno Mattarollo <bmatt-ee4meeAH724@public.gmane.org> Currently in: Sydney, Australia [ http://pokies.typepad.com/virtual_possum/ ] _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails