Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdLL4-0000Rv-Kf for pgsql-general@arkaria.postgresql.org; Wed, 11 Jul 2018 20:03:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdLL2-0000pG-VE for pgsql-general@arkaria.postgresql.org; Wed, 11 Jul 2018 20:03:48 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdLL2-0000p7-Jd for pgsql-general@lists.postgresql.org; Wed, 11 Jul 2018 20:03:48 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdLKz-0003SA-50 for pgsql-general@postgresql.org; Wed, 11 Jul 2018 20:03:47 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 425E821CEF; Wed, 11 Jul 2018 16:03:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 11 Jul 2018 16:03:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=8T56fm9bL4AcMkMpPGcDFayWxpYl5 NI+hFcM0iIg9so=; b=etADNp55Nkm9O2GuaNpGqcojvxwxin1+5D9SfankovBzk cbHGiH7L86TMUuyz+wPf8bWeLM2epncZvPbL5u1+c/0Zw+awFqA5DPoUge8+nDp3 SpLLZbqjB7j9eJeIpqx4FmLTj0cFE0KroYB451w9aUPj8RFsnbBSpfQk+QrqEXwt fGDBTykqmQNpgyOs1u6pNvcNhja0yIey2wDkq5voJb64UWGTnwn6JHQSD10497vW DRnsb206wfUVGGJsSRGmMZVpS3xbu7ATK4t3TohFw28+EcsouF9BQL+NsoT7p8ST bll/9VDq1cLbEfOKV7FJPH4V2SstOEJC9xXfEA5Ig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=8T56fm 9bL4AcMkMpPGcDFayWxpYl5NI+hFcM0iIg9so=; b=Xphu4Z88ok2CPjxiL/J8Qs f9GWoRez/U9dKlgxJmub2ll7S/Wemzeou+GRQ/flfSY34lSjB3U6XgdXHgEcAAXh ozjoQ1da1t1NhFjXQgRmmgGS8EIgsSuMQ9nHITORMMjB7girE3CSN0Z26gm0Jz0C iapV808N4dC/1F61wulKvR6tuLRMEdL7KpXsXrFYcJSa9uJMFGNn4JrsqMvcaQll /Kd+AxFzd7whlvCJAj59BGbFwKiiYxwfG9jW6tJKg7hMwkEKT+5OAynZ4YObmoCA OFMntxnOX4nvSFmCFnw53NhA7VgVwVHOjR8af5FTpCqTNZ+V4dXpWSJAXax/hxrA == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 471AA10269; Wed, 11 Jul 2018 16:03:43 -0400 (EDT) Subject: Re: timestamp (military) at time zone without the suffix To: David Gauthier , "David G. Johnston" Cc: "pgsql-general@postgresql.org" References: From: Adrian Klaver Message-ID: <6e077137-2177-7793-e572-9b56226d67a0@aklaver.com> Date: Wed, 11 Jul 2018 13:03:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/11/2018 12:59 PM, David Gauthier wrote: > OK, the "to_char" gets rid of the timezone extension.  But the times > still don't make sense. > > UTC should be 5 hours ahead, not behind.  It should be EST plus 5 hours > (or 4 for DST), not minus.  That's why I said I expected 20:27 . > > > When I go to store this in a DB, I want to store the UTC time.  How d I > do that ? > > insert into foo (dt) values (localtimestamp(0) at time zone 'utc') ??? What is the data type for foo.dt? > > > On Wed, Jul 11, 2018 at 3:45 PM, David G. Johnston > > wrote: > > On Wednesday, July 11, 2018, David Gauthier > > wrote: > > Hi: > > I would like to get the utc timestamp, 24-hr clock (military > time), without the time zone suffix. > > Below commands were run nearly at the same time... > > sqfdev=> select now()::timestamp(0)  ; >          now > --------------------- >  2018-07-11 15:27:12 > (1 row) > > ...then immediately... > > sqfdev=> select now()::timestamp(0) at time zone 'utc' ; >         timezone > ------------------------ >  2018-07-11 11:27:12-04 > (1 row) > > > 15:27:12 makes sense (it's a bout 3:30 in the afternoon EST). > 11:27:12 doesn't make sense.  UTC is 5 hours ahead. > > Apparently it's only four hours ahead of your server's time zone > setting. > >   I would have expected either 20:27 (if it stuck to military > time, which I want), or 08:27 (P.M., non-military time) > > And I want to get rid of the -04 suffix. > > Is there a way to do this ? > > > Specify an appropriate format string with the to_char function. > > https://www.postgresql.org/docs/10/static/functions-formatting.html > > > David J. > > -- Adrian Klaver adrian.klaver@aklaver.com