pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David Gauthier <davegauthierpg@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: timestamp (military) at time zone without the suffix
Date: Wed, 11 Jul 2018 13:03:42 -0700
Message-ID: <6e077137-2177-7793-e572-9b56226d67a0@aklaver.com> (raw)
In-Reply-To: <CAMBRECBnkee2fG3kWFCFFRfk=Eq40obKkzOL1181H_phZhRtRA@mail.gmail.com>
References: <CAMBRECB=k1CkGjvY-nn=WMtcVFM8f_88D6MK+Bt=jCbHVOpbWA@mail.gmail.com>
	<CAKFQuwa1UR9pAr+ZSo=C5FUAMdv0yNd432eA0EQF5cJ8i7RQaQ@mail.gmail.com>
	<CAMBRECBnkee2fG3kWFCFFRfk=Eq40obKkzOL1181H_phZhRtRA@mail.gmail.com>

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 
> <david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com>> wrote:
> 
>     On Wednesday, July 11, 2018, David Gauthier
>     <davegauthierpg@gmail.com <mailto:davegauthierpg@gmail.com>> 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
>     <https://www.postgresql.org/docs/10/static/functions-formatting.html;
> 
>     David J.
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (13+ messages)  latest in thread

Message-ID: <6e077137-2177-7793-e572-9b56226d67a0@aklaver.com>
Permalink:  ../6e077137-2177-7793-e572-9b56226d67a0@aklaver.com/
Also on:    postgresql.org/message-id/6e077137-2177-7793-e572-9b56226d67a0@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, davegauthierpg@gmail.com, david.g.johnston@gmail.com
  Subject: Re: timestamp (military) at time zone without the suffix
  In-Reply-To: <6e077137-2177-7793-e572-9b56226d67a0@aklaver.com>
  References: <CAMBRECB=k1CkGjvY-nn=WMtcVFM8f_88D6MK+Bt=jCbHVOpbWA@mail.gmail.com> <CAKFQuwa1UR9pAr+ZSo=C5FUAMdv0yNd432eA0EQF5cJ8i7RQaQ@mail.gmail.com> <CAMBRECBnkee2fG3kWFCFFRfk=Eq40obKkzOL1181H_phZhRtRA@mail.gmail.com> <6e077137-2177-7793-e572-9b56226d67a0@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox