Re: timestamp (military) at time zone without the suffix
В списке pgsql-general по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: timestamp (military) at time zone without the suffix |
| Дата | |
| Msg-id | 5402.1531338876@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | timestamp (military) at time zone without the suffix (David Gauthier <davegauthierpg@gmail.com>) |
| Список | pgsql-general |
David Gauthier <davegauthierpg@gmail.com> writes:
> sqfdev=> select now()::timestamp(0) at time zone 'utc' ;
> timezone
> ------------------------
> 2018-07-11 11:27:12-04
> (1 row)
You're doing it wrong: coercing to timestamp already involves a rotation
to local time, and then "at time zone" says to interpret that as a time
in UTC, and the output is a timestamptz which will be displayed in your
local time.
I think the result you want is more like
select (now() at time zone 'utc')::timestamp(0);
although personally I'd choose some other way of dropping the fractional
second, probably
select current_timestamp(0) at time zone 'utc';
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера