agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
Getting wrong time using now()
3+ messages / 3 participants
[nested] [flat]

* Getting wrong time using now()
@ 2019-02-12 23:36  Om Prakash Jaiswal <op12om@yahoo.co.in>
  0 siblings, 2 replies; 3+ messages in thread

From: Om Prakash Jaiswal @ 2019-02-12 23:36 UTC (permalink / raw)
  To: Postgres General <pgsql-general@postgresql.org>; pgsql-sql

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

RegardsOm PrakashBangalore, India

Sent from Yahoo Mail on Android

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Getting wrong time using now()
@ 2019-02-12 23:40  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Om Prakash Jaiswal <op12om@yahoo.co.in>
  1 sibling, 0 replies; 3+ messages in thread

From: Adrian Klaver @ 2019-02-12 23:40 UTC (permalink / raw)
  To: op12om@yahoo.co.in <op12om@yahoo.co.in>; Postgres General <pgsql-general@postgresql.org>; pgsql-sql

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 
> <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__Android...;


-- 
Adrian Klaver
adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Getting wrong time using now()
@ 2019-02-12 23:46  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Om Prakash Jaiswal <op12om@yahoo.co.in>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2019-02-12 23:46 UTC (permalink / raw)
  To: op12om@yahoo.co.in <op12om@yahoo.co.in>; +Cc: Postgres General <pgsql-general@postgresql.org>; pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-02-12 23:46 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 23:36 Getting wrong time using now() Om Prakash Jaiswal <op12om@yahoo.co.in>
2019-02-12 23:40 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-02-12 23:46 ` Tom Lane <tgl@sss.pgh.pa.us>

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