P
Prisma5mo ago
PinkWith

Could you help me analyze this time zone issue?

Environment: Prisma 6.11 / Mysql 8.0 1. Does Prisma support setting the time zone in the connection parameters? My actual local time zone is UTC+8 (Beijing, China). The following picture shows the result of querying the time zone of my MySQL server. Note: It should be noted that the time zone shown in the picture is the time zone obtained by directly connecting to the database and querying using a database connection tool. Therefore, the time zone of this session and the MySQL server is "system", representing the Beijing time zone. I configured the NewYork time zone in my connection. DATABASE_URL="mysql://root:root@localhost:3306/fandian?time_zone=America/New_York" But when I query the time zone through Prisma, what I get is
export async function selectGlobalTimeZone() {
const timeZone =
await prisma.$queryRaw`SELECT @@GLOBAL.time_zone, @@SESSION.time_zone`;
console.log("timeZone", timeZone);
return timeZone;
}
export async function selectGlobalTimeZone() {
const timeZone =
await prisma.$queryRaw`SELECT @@GLOBAL.time_zone, @@SESSION.time_zone`;
console.log("timeZone", timeZone);
return timeZone;
}
log: timeZone [ { '@@GLOBAL.time_zone': 'SYSTEM', '@@SESSION.time_zone': 'SYSTEM' } ] That is to say, the time zone set in the DATABASE_URL connection has not taken effect.
No description
1 Reply
Nurul
Nurul5mo ago
Related issue: https://github.com/prisma/prisma/issues/5051 It's not natively supported yet. You can manually set the session time zone at the start of each connection using raw queries though
GitHub
Improve Timezone Support for Existing MySQL Databases configured wi...
Bug description The OS and MySQL time both are set to KST(Korea Standard Time) which is UTC+9:00. But when create or update records with new Date(), DATETIME string doesn't respect the database...

Did you find this page helpful?