Prisma Date Day Off

Hello, I currently have the following:
model SomeModel {
date DateTime @db.Date()
}
model SomeModel {
date DateTime @db.Date()
}
prisma.somemodel.insert({
data: {
date: new Date("2023-06-10")
}
});
prisma.somemodel.insert({
data: {
date: new Date("2023-06-10")
}
});
but the problem is that it saves the date as 2023-06-09 in the PostgreSQL database. Idk how to fix this
Solution:
I just added UTC after the day, got fixed, thanks 🙂
Jump to solution
3 Replies
Grey
Grey•12mo ago
postgres saves time in the UTC +0 Timestamp in your case the new Date() is auto timestamped to your local time, and when passing to postgres, it is converted from your local time to UTC in which case it has a chance to go to the previous day example if you life in UTC+2 and run the insert statement at 10 June 2023, 01:00 AM, when passing to postgres it is converted to 09 June 2023, 11:00 PM as UTC is behind by 2 hours so to fix it just timestamp your date
EQ
EQ•12mo ago
Ah okay, thanks
Solution
EQ
EQ•12mo ago
I just added UTC after the day, got fixed, thanks 🙂