Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eqloY-0002iE-2j for pgsql-general@arkaria.postgresql.org; Tue, 27 Feb 2018 20:25:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eqloW-0005Do-B4 for pgsql-general@arkaria.postgresql.org; Tue, 27 Feb 2018 20:25:28 +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 1eqloV-0005De-JA for pgsql-general@lists.postgresql.org; Tue, 27 Feb 2018 20:25:28 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eqloS-0004Vl-G3 for pgsql-general@postgresql.org; Tue, 27 Feb 2018 20:25:26 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E5A01219C4; Tue, 27 Feb 2018 15:25:21 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Tue, 27 Feb 2018 15:25:21 -0500 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=fm2; bh=9bkw2xJ1OkYITlBqbAOY9f1RnvtkS QIZ4prYQ4S/R8k=; b=P8FptLBam6fMw0NVlvOFa0qMBKRogEwhFTjrNQvRDXQh6 Ydn9pSCXgitm8n/ETsDe01MRPrvkb52HmPKwelstlZwuHEyKqP9Ozj4fvV4KDSku N5qsyg85eX0CB9jx6WEEsqWc5pA61zDYz2gk9Sdo8u2R8L7DH3HS9uXaA2UIANnq 2a7NNDWgDTwkI/Tqw34BIgA8DCeFi15eV6NsKxtnwNZfu4VgsA9bXc9IVs5Wi3zF rJRpWLQb7HdJ70o+vmYSB2ufvHwiJsH4lc10JzdF840LLZC2VWPFbQjRiyU1JKGy iBiAZmxlcY6dL+Fwo8CG497FUng2sC2YOo4SUDZ7g== 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=fm2; bh=9bkw2x J1OkYITlBqbAOY9f1RnvtkSQIZ4prYQ4S/R8k=; b=HXdy4NX/zxeQ4Xa8nvAPQy uqwaRFoLgdAmUWAhS8cWl7S5B0l7XpSNnaYdTF9nCFbxWabJRn7BkkT6b5I7+b+w ln/fxC5qb6/sUJUU4Cr+aSpytbK0PUVlebgviTAJvtJmz7utYzJthdCXXuD4RjSS Z07V3H30V/42CIQuEWOdJLvTkeFGwXa5brDMvwX2NaWpnzOLHGaSjpwNClHlFuVX cbR4PVH+ivPYuwqxRSHK3BfXTG8yoK6Y1rNJ+uSRvFpMsZ8yl2nxgEqOWq9ewETs 9nUnd5TGGhgowC5lmfrM2yVfEZb60/wUYqtWUlEACmqtH1LKaioAb9+3viF5wE7w == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id 5E9387E270; Tue, 27 Feb 2018 15:25:21 -0500 (EST) Subject: Re: selecting timestamp To: chris , Postgres General References: <0a80c0d7-3c90-3051-3835-8d973db8bdc4@pgsqlrocket.com> <32ecec3a-654d-25e5-75ea-ccd7e2331429@pgsqlrocket.com> From: Adrian Klaver Message-ID: <3a7ad900-251d-2b04-602c-b478e792f0bc@aklaver.com> Date: Tue, 27 Feb 2018 12:25:20 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <32ecec3a-654d-25e5-75ea-ccd7e2331429@pgsqlrocket.com> 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 02/27/2018 12:16 PM, chris wrote: > > What is the best way of selecting current timestamp in UTC? > > SELECT > CURRENT_TIMESTAMP   as ct1 Well the above would depend on your database having its time zone set to UTC. > ,timezone('UTC',CURRENT_TIMESTAMP) as ct2 > ,timezone('utc',now()) as ct3 > ,CURRENT_TIMESTAMP at time zone 'UTC' as ct4 > ,NOW() at time zone 'utc' as ct5 The rest would do the job. The question becomes where are you planning on calling these and what is tine you are looking for? See the below for more information: https://www.postgresql.org/docs/10/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT Basically the functions act differently in transactions, which will affect the time returned. -- Adrian Klaver adrian.klaver@aklaver.com