简体   繁体   English

node.js,mysql,日期时间和时间偏移

[英]node.js, mysql, datetime and time offset

I have a connection to a mariadb instance using the mysql module for node: 我使用节点的mysql模块连接到mariadb实例:

Node module, mysql: "version": "2.5.3", "license": "MIT", "author": { "name": "Felix Geisendörfer", ... 节点模块,mysql:“版本”:“ 2.5.3”,“许可证”:“ MIT”,“作者”:{“名称”:“ FelixGeisendörfer”,...

Node, version v0.12.0 节点,版本v0.12.0

I am using am using a connection pool to access mysql: 我正在使用连接池访问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 在我的数据库中,表中有一个datetime字段,该字段设置为: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) 但是,当我从数据库查询此消息时,响应为:Thu Jun 11 2015 10:25:43 GMT + 0100(格林尼治标准时间夏令时间)

My question is why is GMT+0100 being applied to the response? 我的问题是为什么将GMT + 0100应用于响应?

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. 从数据库中读取日期后,调用'.toUTCString()'方法将返回正确的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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