简体   繁体   中英

node.js, mysql, datetime and time offset

I have a connection to a mariadb instance using the mysql module for node:

Node module, mysql: "version": "2.5.3", "license": "MIT", "author": { "name": "Felix Geisendörfer", ...

Node, version v0.12.0

I am using am using a connection pool to access mysql:

mysqlPool = mysql.createPool({
  'host':'myhost',
  'port':'3306',
  'database':'mydb',
  'user':'root',
  'password':'mypass',
  'timezone':'utc'
});

In my database I have a datetime field in a table that is set as: 2015-06-11 09:25:43

However when I query this from the database the response is: Thu Jun 11 2015 10:25:43 GMT+0100 (GMT Daylight Time)

My question is why is GMT+0100 being applied to the response?

Thank you,

It isn't a fix but a work around.

After reading the date from the database, calling the '.toUTCString()' method returns the correct time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM