X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E3301D1E917 for ; Tue, 16 Mar 2004 17:56:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 64684-09 for ; Tue, 16 Mar 2004 13:56:51 -0400 (AST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.185]) by svr1.postgresql.org (Postfix) with ESMTP id 5F419D1B4DB for ; Tue, 16 Mar 2004 13:56:48 -0400 (AST) Received: from [212.227.126.205] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1B3Io3-0000PM-00; Tue, 16 Mar 2004 18:56:47 +0100 Received: from [80.146.144.54] (helo=lorien.finner.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1B3Io3-0007vC-00; Tue, 16 Mar 2004 18:56:47 +0100 Received: from isengard.finner.de (isengard.finner.de [192.168.14.20]) by lorien.finner.de (Postfix on SuSE Linux 7.3 (i386)) with ESMTP id EDB5D56DB9; Tue, 16 Mar 2004 18:56:37 +0100 (CET) Received: by isengard.finner.de (Postfix, from userid 500) id 16D1787FC1; Tue, 16 Mar 2004 18:56:35 +0100 (CET) Date: Tue, 16 Mar 2004 18:56:35 +0100 From: Frank Finner To: Gary Stainburn Cc: pgsql-sql@postgresql.org Subject: Re: working with unix timestamp Message-Id: <20040316185635.6189cb69.postgresql@finner.de> In-Reply-To: <200403161654.18049.gary.stainburn@ringways.co.uk> References: <200403161654.18049.gary.stainburn@ringways.co.uk> X-Mailer: Sylpheed version 0.8.10claws72 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:2d1f62c261f062640f582804a7b1040c X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/181 X-Sequence-Number: 17280 On Tue, 16 Mar 2004 16:54:18 +0000 Gary Stainburn sat down, thought long and then wrote: > Hi folks. > > I've got a last_updated field on my stock records of type timestamp. > > This last_updated field I get using the perl code: > > my $timestamp=(stat "$localcsv/VehicleStock.$data_suffix")[10]; > > How can I insert the integer timestamp in $timestamp into my table? I usually use somethinge like the following little function for getting an ISO timestamp. The result is suitable for a PostgreSQL timestamp field (without special timezone). # Subroutine for ISO-Timestamp sub mydatetime { my ($time)=@_; my ($sec,$min,$hou,$mday,$mon,$yea,$wday,$jday,$sz)=localtime($time); if ($sec < 10) {$sec="0".$sec;} if ($min < 10) {$min="0".$min;} if ($hou < 10) {$hou="0".$hou;} if ($mday < 10) {$mday="0".$mday;} $mon++; if ($mon < 10) {$mon="0".$mon;} $yea=$yea+1900; my $t=$yea."-".$mon."-".$mday." ".$hou.":".$min.":".$sec; return $t; } Regards, Frank.