Received: from relay.freestart.hu (mx.freestart.hu [213.197.64.3]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f43C8YA22866 for ; Thu, 3 May 2001 08:08:34 -0400 (EDT) (envelope-from pgerzson@freestart.hu) Received: from jaguar (line-70-32.dial.freestart.hu [213.197.70.32]) by relay.freestart.hu (Postfix) with SMTP id 0A7A52D7F; Thu, 3 May 2001 14:08:44 +0200 (MET DST) Message-ID: <01be01c0d3c9$f7241c40$2248c5d5@jaguar> From: "Gyozo Papp" To: , "Richard Whittaker" References: <5.0.2.1.0.20010502084535.0413d790@mekong.connections.yk.ca> Subject: Re: Unixtime function?... Date: Thu, 3 May 2001 13:33:38 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by postgresql.org id f43C8ZA22867 X-Archive-Number: 200105/7 X-Sequence-Number: 316 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?... yes,there is a function called : - date_part(text, timestamp), and another : - date_trunc(text, timestamp), (from the manual of postgres v7.0.2) For the date_part and date_trunc functions, arguments can be `year', `month', `day', `hour', `minute', and `second', as well as the more specialized quantities `decade', `century', `millennium', `millisecond', and `microsecond'. date_part allows `dow' to return day of week, 'week' to return the ISO-defined week of year, and **`epoch'** to return seconds since 1970 (for timestamp) or 'epoch' to return total elapsed seconds (for interval). (from the manual of PHP ) int mktime (int hour, int minute, int second, int month, int day, int year [, int is_dst]) Returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer containing the number of seconds between the **Unix Epoch ** (January 1 1970) and the time specified. so what you need is, for example: SELECT date_part('epoch', current_timestamp);