You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that MySQL can't store timezones with datetime columns, and that the common wisdom is to store everything in UTC, the default connection config should be 'Z' and not 'local'. There should probably also be a big warning in the docs about how using timezone = 'local' can cause problems.
As an example of how the 'local' default can cause subtle bugs, the file test/integration/connection/test-type-casting.js contains the following test case:
Because the test connection is using the 'local' timezone, this test fails if you are in a timezone with a negative UTC offset. The date will be formatted by SqlString.escape as '2012-05-11 $time', and stored in mysql as '2012-05-11'. When it's retrieved it's parsed as new Date('2011-05-11'). Because there is no time part to the date it's treated as UTC, meaning you end up with a date exactly 24 hours off.
Setting connection.config.timezone = 'Z' "fixes" the test.
The text was updated successfully, but these errors were encountered:
Given that MySQL can't store timezones with datetime columns, and that the common wisdom is to store everything in UTC, the default connection config should be 'Z' and not 'local'. There should probably also be a big warning in the docs about how using timezone = 'local' can cause problems.
As an example of how the 'local' default can cause subtle bugs, the file
test/integration/connection/test-type-casting.js
contains the following test case:Because the test connection is using the 'local' timezone, this test fails if you are in a timezone with a negative UTC offset. The date will be formatted by
SqlString.escape
as '2012-05-11 $time', and stored in mysql as '2012-05-11'. When it's retrieved it's parsed asnew Date('2011-05-11')
. Because there is no time part to the date it's treated as UTC, meaning you end up with a date exactly 24 hours off.Setting
connection.config.timezone = 'Z'
"fixes" the test.The text was updated successfully, but these errors were encountered: