2

What is the data-type for this date type in the postgres?

2020-01-04T16:25:25.000+05:30

if I use with date-time with time zone it will only store 2020-01-04T16:25:25

Can i get some update on this?

7
  • This is timestamp with timezone. so use timestampz to store in database. You can refer this for better understanding Click Here Commented Jul 31, 2020 at 10:56
  • Yes.. but I'm not getting that option.. Commented Jul 31, 2020 at 10:58
  • Just use it as the column's type, e.g. create table t (the_column timestamptz); Commented Jul 31, 2020 at 11:03
  • See the example Commented Jul 31, 2020 at 11:06
  • I'm able add, time with time zone in the postgres default/local db.. but in the server still getting the same problem.. In the both sides I'm using the query.. (CREATE TABLE public.example4 ( date1 timestamptz, date2 timestamptz )) Commented Jul 31, 2020 at 11:45

1 Answer 1

0

I faced this issue once. What I understood at that time, PostgreSQL is defaulted to UTC. Thats why you will always see +00, and not +5.30. To see that, first you have to set the data type as timestamptz ( time stamp with time zone ) , second - you have to set the timeZone. like SET TIMEZONE='Asia/Kolkata' , something like that.

or else, even though you do:

select TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02' AT TIME ZONE 'IST'; 

you will get to see only up to 54.

Sign up to request clarification or add additional context in comments.

1 Comment

To be clear the timestamptz type is UTC. timestamp is not. Also you don't have to SET TIMEZONE, Postgres will pick up the one set for your server. Especially in this case as the timestamp has the offset present and setting the TIMEZONE is redundant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.