Getting wrong time using now()
Getting wrong time using now()
От:
Om Prakash Jaiswal <op12om@yahoo.co.in>
Дата:
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
Regards
Om Prakash
Re: Getting wrong time using now()
От:
Adrian Klaver <adrian.klaver@aklaver.com>
Дата:
On 2/12/19 3:36 PM, Om Prakash Jaiswal wrote: > 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 Move clock back 5:30 hours:). On serious note: 1) I would change the time field to timestamp with timezone. 2) Verify what timezone the server is running on: show timezone; TimeZone ------------ US/Pacific > > > Regards > Om Prakash > Bangalore, India > > Sent from Yahoo Mail on Android > -- Adrian Klaver adrian.klaver@aklaver.com
Re: Getting wrong time using now()
От:
Adrian Klaver <adrian.klaver@aklaver.com>
Дата:
On 2/12/19 3:36 PM, Om Prakash Jaiswal wrote: > 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 Move clock back 5:30 hours:). On serious note: 1) I would change the time field to timestamp with timezone. 2) Verify what timezone the server is running on: show timezone; TimeZone ------------ US/Pacific > > > Regards > Om Prakash > Bangalore, India > > Sent from Yahoo Mail on Android > -- Adrian Klaver adrian.klaver@aklaver.com
Re: Getting wrong time using now()
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Om Prakash Jaiswal 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
Re: Getting wrong time using now()
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Om Prakash Jaiswal 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