PrismaORM shifting the UTC time from my db to the timezone of my application

  Kiến thức lập trình

I have records with timestamp fields in mySql DB. Like this: 2024-06-26T19:00:00.000Z
But when I retrieve these records with prisma, they are converted back to my timezone, so the UTC time in database converts to +5 : 2024-06-27T00:00:00.000Z. However the timezone of my application is in UTC: TZ='UTC'.

when printing new Date() in my NestJs application, it logs the current date in UTC format, but when selecting the date value from mySql DB, it converts this value to +5. So what I want is to work with this date value retrieved from db and be able to compare it with current date without hardcoding.

Is there any ways to stop prisma from converting UTC dates of db to my timezone when retrieving?

I tried to set the timezone of my application to UTC. And it is indeed UTC as new Date() returns UTC value. My prisma module also looks like this:

model Event {
...
    dateStart             DateTime @map("datestart") 
    dateEnd               DateTime @map("dateend") 

...

}

I have tried adding params like @db.Timestamp(), but it did not work

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT