-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
To view:https://node-postgres.com/features/types ->date / timestamp / timestamptz
create table:
CREATE TEMP TABLE dates(
date_col DATE,
timestamp_col TIMESTAMP,
timestamptz_col TIMESTAMPTZ,
);
Insert first,then query.
E:\nodejs_space\hello>node time.js
process.env.TZ = Asia/Shanghai
now = Tue Oct 27 2020 10:08:28 GMT+0800 (GMT+08:00)
prepareValue = 2020-10-27T02:08:28.816Z
dateToString = 2020-10-27T10:08:28.816+08:00
[
{
date_col: 2020-10-26T16:00:00.000Z,
timestamp_col: 2020-10-27T02:08:28.816Z,
timestamptz_col: 2020-10-27T02:08:28.816Z
}
]
output psql: (insert time type was right)
highgo=# select * from public.dates;
date_col | timestamp_col | timestamptz_col
------------+-------------------------+----------------------------
2020-10-27 | 2020-10-27 10:08:28.816 | 2020-10-27 10:08:28.816+08
(1 row)
Why is the value of the time type different?
psql:---2020-10-27 10:08:28.816
timestamp_col:--- 2020-10-27T02:08:28.816Z