Re: Getting wrong time using now() - Mailing list pgsql-general

From Tom Lane
Subject Re: Getting wrong time using now()
Date
Msg-id 16352.1550015207@sss.pgh.pa.us
Whole thread Raw
In response to Getting wrong time using now()  (Om Prakash Jaiswal <op12om@yahoo.co.in>)
List pgsql-general
Om Prakash Jaiswal <op12om@yahoo.co.in> writes:
> Create table service_record(Id into, time timestamp without time zone default now()).Postgresql version 9.6.6,
RHEL7.6, when I am executing the query. I am getting time 5:30hours behind current time. Please solve it 

Well, you probably ought to be using LOCALTIMESTAMP, not now(),
as the initializer for a "timestamp without time zone" value,
if only to save a useless runtime datatype conversion.  See

https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

However, if the results don't look right to you, it probably
means that you don't have the timezone parameter set correctly.

            regards, tom lane


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Getting wrong time using now()
Next
From: Rich Shepard
Date:
Subject: Re: Subquery to select max(date) value