When storing timestamps in jsonb I realized the format used when putting current_timestamp and now() into a jsonb was different than when I used them directly. What is going on here? Although both are ISO8601 formats, I would prefer that they both use the same formatting. Why is there two different defaults?
select version(); select now(); select current_timestamp; select jsonb_build_object('timestamptz', current_timestamp); select jsonb_build_object('timestamptz', now());| version | | :----------------------------------------------------------------------------------------------------- | | PostgreSQL 12.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4), 64-bit | | now | | :---------------------------- | | 2022-07-14 14:13:42.696612+01 | | current_timestamp | | :---------------------------- | | 2022-07-14 14:13:42.696612+01 | | jsonb_build_object | | :-------------------------------------------------- | | {"timestamptz": "2022-07-14T14:13:42.696612+01:00"} | | jsonb_build_object | | :-------------------------------------------------- | | {"timestamptz": "2022-07-14T14:13:42.696612+01:00"} |
db<>fiddle here