#Wrong datetime in database

15 messages · Page 1 of 1 (latest)

coral willow
#

Hello ! I've setup my docker timezone to Europe/Paris.

And yet, the "createAt" field is 2 hours behind Paris time. I think this is caused by Prisma. Do you have any idea how to fix the problem? (I'm using Postgres)

createdAt DateTime @default(now())

proper crow
#

I'm having the same problem with the "America/Sao_Paulo" (UTC -3) time zone, if you find an answer, could you please answer me?

coral willow
#

alright!

stark stump
#

Check out @db.Timestamptz(x)

proper crow
#

@coral willow what version you use of prisma? This version 5.0.0 have a problem with datetime. I went back to 4.17.0-dev.61 and it works correctly

coral willow
proper crow
#

I saw that it only worked on one of my tables, the others were the same and with the same configuration. the prism actually has a datetime deficit

#

😂

coral willow
#

We are stuck in the prisma matrix

#

@eager knot do you know a solution ? 😁

proper crow
#

@coral willow Hello bro, I solved this error/bug with this table model:

createdAt DateTime @default(dbgenerated("CURRENT_TIMESTAMP(0)")) @db.DateTime(0)

When using "now()" in place of "dbgenerated("CURRENT_TIMESTAMP(0)")", this doesn't work

#

I'm use the 4.0.0 version to test, now i will update

coral willow
proper crow
#

You welcome bro!

proud cobalt
#

I'm in trouble running Prisma 5.4.2 with MySQL 8.1: DateTime works fine with dates in the past or close to the year, but rejects dates in the future. Example:

ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1292, message: "Incorrect datetime value: '2041-12-05 04:00:00.000' for column 'xxx' at row 1", state: "22007" })), transient: false })
log.ts:84

Note the year: 2041... just replacing it by 2037 works fine.

The database field type is timestamp and it´s define as @db.Timestamp(3) in my schema.