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 1fdMRq-0003kC-Ez for pgsql-general@arkaria.postgresql.org; Wed, 11 Jul 2018 21:14:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdMRo-0000c6-ET for pgsql-general@arkaria.postgresql.org; Wed, 11 Jul 2018 21:14:52 +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 1fdMRm-0000bz-Nb for pgsql-general@lists.postgresql.org; Wed, 11 Jul 2018 21:14:52 +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 1fdMRe-0005Ju-Dt for pgsql-general@postgresql.org; Wed, 11 Jul 2018 21:14:49 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E6DAA21957; Wed, 11 Jul 2018 17:14:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 11 Jul 2018 17:14:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= 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=CbWgsj9YI/RJ8gh1hFE1ZXkw80ISX Xb6+/Bhz4SfswE=; b=Fjyt9/eAzQ164450Q/z4GVUMDfFqiMx0VmaHdR0Pj4v2u 32jrcktC9pAJdYSWtZfwtJl1F47u4V2km8Tk9Sfllkcr3MoxxKqOFHeMEgt5epws M4eJZqn/IsaAII4wAl5FmJ7NyNIKvBkFoBJHjpGMD6UPaQ7wTtjlWvgJ1DbXSrdi SBErvff4QoS8KfLftTzzGezwuCKIOBuJ+1OBnEBaxeuAyvgvqbgUVewtar6wWcxa 9ZH7NGJZ2l4G5o+ceGWEHOVtAU7iMae6EFMN2D5he1NTvz2jivNOokc8caCX9u0F BvEncTh4Dwo//oMc7cDFWQuFB3Q4J0mTdp9oO/9/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=CbWgsj 9YI/RJ8gh1hFE1ZXkw80ISXXb6+/Bhz4SfswE=; b=fte2Sl+PcwTJifpCb+P6/l wtzT1jtJdpuhTpDq7JHWBU4C7g29b67+Tk66YU6YlLCR8uUtP71Bm1u9SsPQhwxn Ap2Rpphg3BJgwuOw1BA76etLff726TsgYBXmB3na3NlgEueepZDYRot7AGrpAVV7 raHYLDULRCd5HEgRlYUt3vYodRw/w9ziiUZW+EHUoGkgHu8se4dqXcc1a0OTadvM 0nAe0v3oYthO/GIz5A6YEWUA3Ire91COXKiM0O22O//LDYjBeB15k+fNNvTFvvck J0Xa2hPoQLsn0P3XLZ5fOei9OyHtK8jwN6b7Sn0UkIYwSX14TRdKmqK3zAwpgDxg == X-ME-Proxy: X-ME-Sender: Received: from ranger.suse (unknown [74.94.73.222]) by mail.messagingengine.com (Postfix) with ESMTPA id 0A0E610279; Wed, 11 Jul 2018 17:14:39 -0400 (EDT) Subject: Re: timestamp (military) at time zone without the suffix To: David Gauthier , "pgsql-general@postgresql.org" References: From: Adrian Klaver Message-ID: <84450581-6f59-cf88-ee2c-eaa03f9bba87@aklaver.com> Date: Wed, 11 Jul 2018 14:14:39 -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 01:34 PM, David Gauthier wrote: > Thanks Everyone, they all work, but TL's seems to be the simplest... > select current_timestamp(0) at time zone 'utc' > > I'm kinda stuck with the timestamp data type (vs timestamptz). > Wondering if I can stick with that. The above is at little unclear. Can you change the data type or not? If you can your life will be a lot easier if you change it to timestamptz. > > One last question... > I want to store the current UTC date/time in the DB.  Does PG > unconditionally store something like UTC, then let the queries figure > out how they want to look at it (with "at time zone" and "to_char()" > etc...) ?  Or do I have to intentionally store the UTC value somehow? Per: https://www.postgresql.org/docs/10/static/datatype-datetime.html "For timestamp with time zone, the internally stored value is always in UTC (Universal Coordinated Time, traditionally known as Greenwich Mean Time, GMT). An input value that has an explicit time zone specified is converted to UTC using the appropriate offset for that time zone. If no time zone is stated in the input string, then it is assumed to be in the time zone indicated by the system's TimeZone parameter, and is converted to UTC using the offset for the timezone zone. When a timestamp with time zone value is output, it is always converted from UTC to the current timezone zone, and displayed as local time in that zone. To see the time in another time zone, either change timezone or use the AT TIME ZONE construct (see Section 9.9.3). Conversions between timestamp without time zone and timestamp with time zone normally assume that the timestamp without time zone value should be taken or given as timezone local time. A different time zone can be specified for the conversion using AT TIME ZONE." > > Right now the code is just inserting and updating records using > "localtimestamp(0)". > > > > > On Wed, Jul 11, 2018 at 4:11 PM, David G. Johnston > > wrote: > > On Wednesday, July 11, 2018, David Gauthier > > wrote: > > OK, the "to_char" gets rid of the timezone extension.  But the > times still don't make sense. > > When I go to store this in a DB, I want to store the UTC time. > How d I do that ? > > > Use the data type that represents exactly that, timestamptz.  Using > the timestamp data type is generally not what you want even if you > can get the manipulation logic figured out. > > David J. > > -- Adrian Klaver adrian.klaver@aklaver.com