Postgresql datetimes are not ISO-8601 compliant, but RFC3339 - Mailing list pgsql-bugs

From Leon Timmermans
Subject Postgresql datetimes are not ISO-8601 compliant, but RFC3339
Date
Msg-id CAHhgV8hKWA8JtWEqzhAj-eA9TenG-iu620ZsaxJnFAYMiE6A2A@mail.gmail.com
Whole thread Raw
Responses Re: Postgresql datetimes are not ISO-8601 compliant, but RFC3339
List pgsql-bugs
Postgresql calls its datetime format ISO-8601 in the documentation and in the DateStyle setting, but it is in fact not ISO compliant, but RFC3339 instead. To quote the latter (which is freely available unlike the ISO standard):

  NOTE: ISO 8601 defines date and time separated by "T".
      Applications using this syntax may choose, for the sake of
      readability, to specify a full-date and full-time separated by
      (say) a space character.

Basically instead of outputting «2022-02-12 02:53:59.55718+01», it should output «2022-02-12T02:53:59.55718+01» to be compliant. Fortunately it will accept compliant datetimes as input just fine. I ran into this because I was feeding these values into a strict ISO-8601 implementation and it rejected these values.

The solution that I would suggest for the next major release is to add a new RFC DateStyle with the current behavior and make the ISO setting do the conformant thing; and on existing release series add RFC as an alias of ISO to facilitate the transition for people who may rely on the current behavior.

Regards,

Leon

pgsql-bugs by date:

Previous
From: Troy Frericks
Date:
Subject: A bug with the TimeStampTZ data type and the 'AT TIME ZONE' clause
Next
From: "David G. Johnston"
Date:
Subject: Re: Postgresql datetimes are not ISO-8601 compliant, but RFC3339