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?
ISO 8601 Formats ISO 8601 represents date and time by starting with the year, followed by the month, the day, the hour, the minutes, seconds and milliseconds. For example, 2020-07-10 15:00:00.000, represents the 10th of July 2020 at 3 p.m. (in local time as there is no time zone offset specified—more on that below).
The date format for the date data type in PostgreSQL is yyyy-mm-dd . This is the format used for both storing data and for inserting data.
Use dd/mm/yyyy for numeric date representations. Use mm/dd/yyyy for numeric date representations. A value for SET DATESTYLE can be one from the first list (output styles), or one from the second list (substyles), or one from each separated by a comma.
toISOString() method is used to convert the given date object's contents into a string in ISO format (ISO 8601) i.e, in the form of (YYYY-MM-DDTHH:mm:ss. sssZ or ±YYYYYY-MM-DDTHH:mm:ss. sssZ). The date object is created using date() constructor.
Type "timestamp with time zone" is what you want.
http://www.postgresql.org/docs/current/static/datatype-datetime.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With