Code Monkey home page Code Monkey logo

Comments (2)

drichardcarl avatar drichardcarl commented on July 29, 2024

Same Issue !!!

Model definition

model Entity {
  ...
  createdAt            DateTime              @default(now()) @map("created_at")
  updatedAt            DateTime              @default(now()) @map("updated_at")
  ...
}

MySQL DDL

CREATE TABLE `entities` (
  ...
  `created_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  `updated_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  ...
);

DB rows
image

Returned by Prisma client
image

Prisma Version

...
"@prisma/client": "^5.13.0",
"prisma": "^5.13.0",
...

Edit

It turn's out there's no bug in the first place. I'm currently using Prisma in Remix and I totally forgot that the data I received on my component/frontend code actually crossed between server and client, hence, the datetime field on the server part (which is actually a native Date) gets serialized when received on frontend code.

I'm not so sure if that might also be the case for your @JoaoVitorLima242 .

image

from prisma.

SevInf avatar SevInf commented on July 29, 2024

Hi @drichardcarl.
Technicality, but Prisma does not return DateTime fields as strings, but rather, as JS Date objects which don't store the timezone. Non-UTC dates is one of the Prisma's weak spot which we are very well aware of and hope to fix one day.

If I understood correctly, in your case you always want to format the dates in GMT-3:00. If that's the case, result extension might provide some releif:

const prisma = new PrismaClient().$extends({
  result: {
    User: {
      createdAt: {
        needs: ['createdAt'],
        compute: (user) => formatInTheRightTimzone(user.createdAt)
      }
    }
  }
})

from prisma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.