typeorm, postgres, express UTC timestamp issue

Viewed 15

DTO class and class-validator > IsISO8601

@IsISO8601({ strict: true, strictSeparator: true })
@IsNotEmpty()
public to_date: Date;

TypeORM Class

@Column({ type: 'timestamp with time zone' })
public to_date: Date;

Table DDL

create table foo ( .., to_dt timestamp with time zone not null DEFAULT (now())

Postgres14.x server timezone is set to UTC. While I am sending to_date from postman as 2022-09-06T18:35:28Z(local IST time with a Z at the end), postgres stores and returns the value as 2022-09-06T18:35:28.000Z - which is not correct

But If I am sending to_date value (without a Z at the end) 2022-09-06T18:35:28 or 2022-09-06 18:35 it returns the UTC value as 2022-09-06T13:05:28.000Z which is expected

This is quite confusing. Why Z is making a big difference.

0 Answers
Related