Reputation: 15
So I am displaying a list of objects as MUI Cards on my react application. One of field on the object is of type date
in postgres. For a sample card object, the value retrieved from DB is follows (seen in browser console from logs):
{
"id": 43,
"date": "2024-03-26T00:00:00.000Z",
"vehicle": "MH01EP6194",
...
}
I am displaying the date using dayjs
format method:
dayjs(appt.date).format("DD-MMM-YY")
However the value is displayed as previous day i.e. 25-Mar-2024 instead of 26-Mar-2024. In database the value stored is 2024-03-26
. Any suggestion what I am doing wrong here?
Upvotes: 0
Views: 98
Reputation: 15
Apparently node-postgres module adds server time zone in the date
type column in postgres which was messing with my output. I changed the text parser for date type and it worked:
Date type displaying with timezone on node-postgres module
Upvotes: 0