Re: Re: php, time and postgresql

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: php, time and postgresql
Date: 2001-01-12 22:26:49
Message-ID: 20010112162649.A23581@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 12, 2001 at 02:29:01PM -0700,
Mark Lane <mlane(at)mynewthing(dot)com> wrote:
> On Friday 12 January 2001 14:29, you wrote:
> > How about doing something like this:
> > bruno=> select 'epoch'::timestamp + '979333398 second';
> > ?column?
> > ------------------------
> > 2001-01-12 15:03:18-06
> >
> I Think that is an interesting way of converting unixtime to a timestamp but
> I think he wants to save the time as 979333398 seconds. That would allow him
> to easily convert it to any date/time format when he retrieves it from the
> Database It would also allow for faster sorting if he stored the information
> as an int.

I don't see how storing the time in seconds helps. Once you do that you
can't use the to_date functions to format the output. I also don't see
gaining much in terms of speed either. Timestamps are wider than ints,
but are going to be fast to work with.

While looking for ideas about this I noticed a lack of to_date functions for
printing intervals. I think it would be nice to be able to do something like
the following:
select to_char(now() - 'epoch', 'SSSSSSSSSSSSS');
and get the result:
979333398

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeffery L Post 2001-01-12 22:47:35 Re: Time Formats
Previous Message Tom Lane 2001-01-12 22:09:50 Re: [HACKERS] problems with pg_geqo