X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A1D156454 for ; Fri, 4 Mar 2005 05:47:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37386-05 for ; Fri, 4 Mar 2005 05:47:23 +0000 (GMT) Received: from mail1.elevating.com (wsip-68-99-77-237.tu.ok.cox.net [68.99.77.237]) by svr1.postgresql.org (Postfix) with ESMTP id 490B552A7D for ; Fri, 4 Mar 2005 05:47:21 +0000 (GMT) Received: from bretsony.brets.elevating.com (bretsony.brets.elevating.com [10.23.0.139]) by mail1.elevating.com (8.11.6/8.11.6) with ESMTP id j245lBK30439 for ; Thu, 3 Mar 2005 23:47:11 -0600 Subject: Re: definative way to place secs from epoc into timestamp From: Bret Hughes To: postgresql sql list In-Reply-To: References: <1109780719.28180.86.camel@bretsony> <13089.1109793126@sss.pgh.pa.us> <1109794066.27857.100.camel@bretsony> <13466.1109795186@sss.pgh.pa.us> <1109828560.27905.137.camel@bretsony> <2bf00b6e6300e2c76bc3c09fa89e7913@myrealbox.com> <1109834845.27905.147.camel@bretsony> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 (1.0.8-9.7x.1) Date: 03 Mar 2005 23:47:10 -0600 Message-Id: <1109915231.28180.182.camel@bretsony> Mime-Version: 1.0 X-Elevating-MailScanner: Found to be clean X-Elevating-MailScanner-SpamCheck: not spam, SpamAssassin (score=-1.5, required 5, BAYES_00 -1.50) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/55 X-Sequence-Number: 20534 On Thu, 2005-03-03 at 14:58, Andrew - Supernews wrote: > On 2005-03-03, Bret Hughes wrote: > > a RFE would be to let to_timestamp be to a timezone without time zone > > and have a to_timestamptz do the time zone thing. Seems more consistent > > and would give me the functionality I am looking for :) > > Unix epoch times correspond to timestamp _with_ time zone. > > (Why are you using timestamp without time zone anyway? For recording the > time at which an event occurred that usage is simply wrong - in fact I > can't see any situation in which a Unix epoch time can correctly be > converted to a timestamp without time zone.) > Valid question. Because there is no reason to keep up with time zones and the fact that I want the same value from the data base that I put into it. The app that this db supports is written in php and I kept getting something different out than what I put into it in the other passes I made while trying to get my head around this. the timestamps have historically been stored in flat files. here is an example of a valid use: The table: [bhughes@sonecdm bhughes]$ psql elevating -c '\d testtime' Table "public.testtime" Column | Type | Modifiers --------+-----------------------------+----------- ts | timestamp without time zone | The script: [bhughes@sonecdm elevatetest]$ cat timetest.php #!/usr/bin/php -q The output: [bhughes@sonecdm elevatetest]$ ./timetest.php date from date command Thu Mar 3 22:30:14 EST 2005 system secs 1109907014 php time secs 1109907014 03/03/05 22:30 the number of rows affected was 1 Array ( [0] => 2005-03-03 22:30:14 [ts] => 2005-03-03 22:30:14 [1] => 1109907014 [ts2int] => 1109907014 ) What goes in comes out. Gotta like it. Bret