Feature Summary
Allow users to specify a target timezone for DateTime fields in Prisma Schema or via the connection string for MySQL, ensuring that the stored value matches the specified timezone instead of being forced to UTC.
Use Cases & Problem Description
In MySQL, the DATETIME type does not store timezone metadata. Currently, Prisma's Rust engine forces all DateTime values to be interpreted as UTC. This causes significant issues for regional projects (like those in China, UTC+8) where database administrators and legacy SQL tools expect to see local time in the database. For example, a record created at 15:00 local time is stored as 07:00 by Prisma, making manual database inspection and third-party reporting confusing.
Proposed Solution
Provide a way to specify a storage timezone in the schema or connection string. For example:
model Post {
id Int @id
createdAt DateTime @db.DateTime @Timezone("Asia/Shanghai")
}
Or, make the ?timezone=+08:00 parameter in the MySQL connection string actually affect how the Prisma Query Engine serializes/deserializes DateTime values.
Alternative Solutions
Currently, I have to manually "shift" the time using libraries like Luxon with the 'keepLocalTime: true' flag before saving, and perform the reverse operation after fetching. This adds significant boilerplate and is prone to errors when developers forget to apply the manual conversion.
Potential Considerations
Handling Daylight Saving Time (DST) for certain regions might be complex. It may also introduce inconsistencies if different clients use different timezone settings for the same database.
Prisma Version
7.70
What part of Prisma does this affect?
Prisma Client
Additional Context
This is a very common requirement for developers in regions where local time storage is the standard practice for on-premise or regional databases.
Pre-Submission Checklist
Feature Summary
Allow users to specify a target timezone for DateTime fields in Prisma Schema or via the connection string for MySQL, ensuring that the stored value matches the specified timezone instead of being forced to UTC.
Use Cases & Problem Description
In MySQL, the DATETIME type does not store timezone metadata. Currently, Prisma's Rust engine forces all DateTime values to be interpreted as UTC. This causes significant issues for regional projects (like those in China, UTC+8) where database administrators and legacy SQL tools expect to see local time in the database. For example, a record created at 15:00 local time is stored as 07:00 by Prisma, making manual database inspection and third-party reporting confusing.
Proposed Solution
Provide a way to specify a storage timezone in the schema or connection string. For example:
model Post {
id Int @id
createdAt DateTime @db.DateTime @Timezone("Asia/Shanghai")
}
Or, make the ?timezone=+08:00 parameter in the MySQL connection string actually affect how the Prisma Query Engine serializes/deserializes DateTime values.
Alternative Solutions
Currently, I have to manually "shift" the time using libraries like Luxon with the 'keepLocalTime: true' flag before saving, and perform the reverse operation after fetching. This adds significant boilerplate and is prone to errors when developers forget to apply the manual conversion.
Potential Considerations
Handling Daylight Saving Time (DST) for certain regions might be complex. It may also introduce inconsistencies if different clients use different timezone settings for the same database.
Prisma Version
7.70
What part of Prisma does this affect?
Prisma Client
Additional Context
This is a very common requirement for developers in regions where local time storage is the standard practice for on-premise or regional databases.
Pre-Submission Checklist