By default Laravel uses Y-m-d H:i:s
for datetime parsing and formatting against the database. It gets this value as the connection default.
Postgres uses Y-m-d H:i:s
as the datetime format default for all fields. Except that it does not follow this for datetimes that are serialized as JSON, where it follows ISO 8601 and formats as Y-m-d\TH:i:s
.
Laravel is fortunately able to use a manually set datetime format, so after you hydrate a model with datetime from Postgres JSON with datetimes, you should call $modelInstance->setDateFormat('Y-m-d\TH:i:s');
so that datetimes are parsed correctly. Fortunately, this does not break writing to the db, which seems quite happy to accept ISO 8601 datetime strings.