ISO 8601 format date for PostgreSQL
Asked Answered
E

1

7

I have string containing an ISO 8601 formatted date-time value (ex: 2013-05-21T15:00:00+0200) and time zone (ex: Europe/Rome).

What is the best Postgres data type to represent this date format?

Examine answered 27/5, 2013 at 18:31 Comment(1)
Just for future questions, please always mention your exact PostgreSQL version (select version()). It isn't important for this particular question, but it often will be.Channel
C
9

Type "timestamp with time zone" is what you want.

http://www.postgresql.org/docs/current/static/datatype-datetime.html

Cleaning answered 27/5, 2013 at 18:37 Comment(2)
I have a string in this format: 2013-05-21T15:00:00+0200" and Timezone: "Europe/Rome" How can I use this string into a INSERT query if I use a data type as "timestamp with time zone"? Need I a particular function to conversion a ISO 8601 datetime into timestamp with time zone format?Examine
Postgres doesn't store timezone, it just recalculate timestamp to server timezone. And your timezone is specify by "+200". But INSERT INTO tab(somecol) VALUES('2013-05-21T15:00:00+0200') should workCleaning

© 2022 - 2024 — McMap. All rights reserved.