Received: from shaked.cc.openu.ac.il (shaked.cc.openu.ac.il [147.233.145.65]) by hub.org (8.8.8/8.7.5) with ESMTP id HAA05963 for ; Sun, 6 Sep 1998 07:16:55 -0400 (EDT) Received: from [147.233.159.109] (herouth@mac-herouth.pc.openu.ac.il [147.233.159.109]) by shaked.cc.openu.ac.il (8.8.5/8.8.5) with ESMTP id NAA09132; Sun, 6 Sep 1998 13:16:41 +0200 (IST) X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sun, 6 Sep 1998 13:16:32 +0200 To: lynch@lscorp.com (Richard Lynch), pgsql-sql@postgreSQL.org From: Herouth Maoz Subject: Re: [SQL] Datetime in humane format At 6:27 +0200 on 6/9/98, Richard Lynch wrote: > So, I followed the advice in the archives and used the datetime type. > > Now, I've got entries like 'Sun Sep 06 00:06:57 1998 EDT' in my table. > > So, how do I turn that into something that a normal human can read? > > "Sep 06 1998 12:06 am" would be nice... > > Or, how do I turn that back into seconds since epoch? I'm using PHP which > has a nice date function that I think I can coerce into giving me what I > want... unless it also thinks that humans understand 00:06:57 as just after > midnight... That depends on the country... To me, 24-hour clocks are as natural as hailing a cab. Seconds since epoch - very easy: the function date_part will do that for you. Read the manpage of pgbuiltin. Perhaps its worthwhile to delve into the PHP documentation. Perhaps you can transfer the result you got from a query on a date field directly to some PHP date type which allows formatting. At least in Java that's how it's done - so why not in others. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma