Received: from fslc.ser.usu.edu (fslc.ser.usu.edu [129.123.28.122]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f42KBGA65711 for ; Wed, 2 May 2001 16:11:16 -0400 (EDT) (envelope-from rmello@fslc.usu.edu) Received: (from rmello@localhost) by fslc.ser.usu.edu (8.12.0.Beta5/8.12.0.Beta5/Debian 8.12.0-1) id f42KB7Kt020013; Wed, 2 May 2001 14:11:07 -0600 Date: Wed, 2 May 2001 14:11:07 -0600 From: Roberto Mello To: Richard Whittaker Cc: pgsql-php@postgresql.org Subject: Re: Unixtime function?... Message-ID: <20010502141107.A19986@cc.usu.edu> References: <5.0.2.1.0.20010502084535.0413d790@mekong.connections.yk.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.17i In-Reply-To: <5.0.2.1.0.20010502084535.0413d790@mekong.connections.yk.ca>; from richard@connections.yk.ca on Wed, May 02, 2001 at 08:49:32AM -0700 X-Archive-Number: 200105/4 X-Sequence-Number: 313 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.net http://www.sdl.usu.edu - Space Dynamics Lab, Developer "Windows? What Windows? I use OS/2." (Bill Gates)