From: Roberto Mello <rmello@cc.usu.edu>
To: Richard Whittaker <richard@connections.yk.ca>
Cc: pgsql-php@postgresql.org
Subject: Re: Unixtime function?...
Date: Wed, 2 May 2001 14:11:07 -0600
Message-ID: <20010502141107.A19986@cc.usu.edu> (raw)
In-Reply-To: <5.0.2.1.0.20010502084535.0413d790@mekong.connections.yk.ca>
References: <5.0.2.1.0.20010502084535.0413d790@mekong.connections.yk.ca>
On Wed, May 02, 2001 at 08:49:32AM -0700, Richard Whittaker wrote:
> Greetings:
>
> In MySQL there is a function to convert an arbitrary date/time combination
> to a Unix timestamp, which makes it really easy to perform calculations in
> PHP, since the result was always an integer... Is there a similar function
> out there for PostgresSQL or PHP?...
Some RTFM'ing comes in handy :)
I put "time" in php.net and it returned me the time function manual.
PostgreSQL has lots of functions to work with dates and times,
including to_char and to_date, with tons of functionality. In PG (and Oracle)
dates _are_ integers, even though it's not displayed to you as such:
hgcm-test=# select now();
now
------------------------
2001-05-02 14:08:40-06
hgcm-test=# select now() + 3;
?column?
------------
2001-05-05
hgcm-test=# select now() - 3;
?column?
------------
2001-04-29
Or you could use intervals:
hgcm-test=# select now() + '1 week'::interval;
?column?
------------------------
2001-05-09 14:10:18-06
There's more information in the PostgreSQL documentation.
-Roberto
--
+----| http://fslc.usu.edu USU Free Software & GNU/Linux Club |------+
Roberto Mello - Computer Science, USU - http://www.brasileiro.nethttp://www.sdl.usu.edu - Space Dynamics Lab, Developer
"Windows? What Windows? I use OS/2." (Bill Gates)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: rmello@cc.usu.edu, richard@connections.yk.ca
Subject: Re: Unixtime function?...
In-Reply-To: <20010502141107.A19986@cc.usu.edu>
References: <5.0.2.1.0.20010502084535.0413d790@mekong.connections.yk.ca> <20010502141107.A19986@cc.usu.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox