Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Support for Timezone In xMySQL #43

Open
ShantanuVidwans opened this issue Sep 15, 2022 · 0 comments
Open

No Support for Timezone In xMySQL #43

ShantanuVidwans opened this issue Sep 15, 2022 · 0 comments

Comments

@ShantanuVidwans
Copy link

In NodeJS, when a connection is initialized for mysql, the default timezone is 'UTC'
If the data stored in the database is not in UTC timezone then when xMySQL fetches the data then the same DateTime is not received.
xMySQL returns the UTC time by converting the local time stored in DB to UTC timezone.

Eg: My time zone is IST (->UTC +5:30)
data in db = "2022-02-01" <- The data is stored in IST TimeZone
data i get from xMySQL = "2022-01-31T18:30:00.000Z" <- See the offset of -5:30 due to timezone not set properly

Solution:
I cloned the repo and found a solution for this. The following command line argument can be added, so timezone can also be supported by xMySQL.

cmd.helper.js->
[near line 74]
program.timezone = program.timezone || "UTC"; //default to UTC if no timezone provided

[near line 19]
.option("-t, --timezone ", "set the timezone")

adding this will cause the code to add the timzone parameter in the "sqlConfig".

Internally it would end up like this:
var sqlConfig= {
host : 'localhost',
user : 'xxx',
password : '',
database : 'xxx',
timezone: 'IST' //<-the timzone added after the above code change
};

Comment on this Issue if you choose to use these changes. Will improve my quality of life

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant