3

When I am trying to set the timezone with mysql2 getting the bellow message. With MySQL working fine.

But I have to use mysql2 only

var mysql2 = require('mysql2');

var con = mysql2.createPool({  
connectionLimit : 10, 
host: process.env.DATABASE_HOST, 
user: process.env.DATABASE_USER,  
password: process.env.DATABASE_PASSWORD,  
database : process.env.DATABASE_NAME,  
timezone : 'IST'      
})

Problem

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

S. Hesam
  • 5,266
  • 3
  • 37
  • 59
Sujeet Kumar
  • 1,822
  • 22
  • 25

2 Answers2

1

Here try this as timezone. For IST

timezone: 'Asia/Calcutta'

or

timezone: '+05:30'
xMayank
  • 1,875
  • 2
  • 5
  • 19
  • not working getting this error Ignoring invalid configuration option passed to Connection: dialectOptions. 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 Ignoring invalid timezone passed to Connection: Asia/Calcutta. 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 – Sujeet Kumar Jul 24 '20 at 10:52
  • Updated my answer can you check now ? – xMayank Jul 24 '20 at 10:54
  • again not working timezone : 'IST' is working with MySQL but not working in mysql2 – Sujeet Kumar Jul 24 '20 at 11:03
  • It's working just fine in 2022. – suchislife Sep 08 '22 at 19:00
0

You can find the description about timezone in mysqljs/mysql:

timezone: The timezone configured on the MySQL server. This is used to type cast server date/time values to JavaScript Date object and vice versa. This can be 'local', 'Z', or an offset in the form +HH:MM or -HH:MM. (Default: 'local')

You need to use +05:30 instead of Asia/Calcutta.

Tura
  • 1,227
  • 11
  • 22