node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

Timezone setting is not sure

Open EastWon0103 opened this issue 1 year ago • 2 comments

Hi I'm use a mysql2 at my express server. and I want to set timezone. first I set mysql2 connection configuration like this

{
        host: "dev_db_container",
        user: process.env.DB_USER,
        password: process.env.DB_PASS,
        port: process.env.DB_PORT,
        database: process.env.DB_TEST_NAME,
        timezone: 'Asia/Seoul', 
        charset: "utf8mb4"
}

It works for this project. but I can't use unit test because when I connect mysql2 shows this line

Ignoring invalid timezone passed to Connection: Asia/Seoul. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection

So, I modified configuration code like this

{
        host: "dev_db_container",
        user: process.env.DB_USER,
        password: process.env.DB_PASS,
        port: process.env.DB_PORT,
        database: process.env.DB_TEST_NAME,
        timezone: '+09:00', 
        charset: "utf8mb4"
}

but this setting is not return datetime on kst. How can I fix it? Or remove timezone setting and I adjust it?

EastWon0103 avatar Mar 23 '23 18:03 EastWon0103

I encountered the same situation and set timezone in the connection parameters, but it didn't work.

ylbo avatar Oct 24 '23 11:10 ylbo

Same here. However, after changing the timezone of my DB(in my case, I'm using Docker MariaDB Container) through the command SET GLOBAL time_zone = 'Asia/Seoul', my server returned time on kst. But there is still no change when modifying the timezone option.

do0ori avatar Dec 21 '23 03:12 do0ori