Thread: strtotime() and postgresql date/time output

strtotime() and postgresql date/time output

From
Rien Broekstra
Date:
I have the following problem

I want to save timestamps in a database and use them in a php script.

According to the documentation, postgres's date/time output is possible
in 4 styles. My problem is that the php strtotime() function which I use
to get a timestamp instead of a date/time string does not understand any
of these date/time formats.

- Is it possible to manually define a datestyle so Postgresql returns a
date/time string which  strtotime does understand?
- Is it possible to let Postgresql return just a timestamp instead of a
date/time string
- Is there another function in php which does understand standard ISO or
SQL style date/time strings and converts them to a timestamp?

thanks in advance
--
Rien Broekstra a.k.a Rienzilla
ICQ: 35629366                   The Drunk Snipers: unreal.snt.utwente.nl
Mail: rien@rename-it.student.utwente.nl
                                 Vestingbar: www.vestingbar.nl


Re: strtotime() and postgresql date/time output

From
Timothy_Maguire@hartehanks.com
Date:
When I pull a timestamp from a db, i use the to_char () postgresql
function.  This is real nice because you can convert the months into words
(Jan or January).  Try something like this:

SELECT to_char(timestamp_field, "M") from table;

I forget the exact syntax, but you can find it at postgresql.org under the
users guide.

TIm.




Rien Broekstra <rien@cal018043.student.utwente.nl>@postgresql.org on
01/27/2001 06:39:42 AM

Sent by:  pgsql-php-owner@postgresql.org


To:   pgsql-php@postgresql.org
cc:

Subject:  strtotime() and postgresql date/time output


I have the following problem

I want to save timestamps in a database and use them in a php script.

According to the documentation, postgres's date/time output is possible
in 4 styles. My problem is that the php strtotime() function which I use
to get a timestamp instead of a date/time string does not understand any
of these date/time formats.

- Is it possible to manually define a datestyle so Postgresql returns a
date/time string which  strtotime does understand?
- Is it possible to let Postgresql return just a timestamp instead of a
date/time string
- Is there another function in php which does understand standard ISO or
SQL style date/time strings and converts them to a timestamp?

thanks in advance
--
Rien Broekstra a.k.a Rienzilla
ICQ: 35629366                   The Drunk Snipers: unreal.snt.utwente.nl
Mail: rien@rename-it.student.utwente.nl
                                 Vestingbar: www.vestingbar.nl