我有预订表。当我选择的用户SELECT * FROM booking WHERE guestId='3';
一些订单我有:发送到前端后,mysql列的日期发生更改
+-----------+------------+------------+--------+---------+
| bookingId | startDate | endDate | roomId | guestId |
+-----------+------------+------------+--------+---------+
| 3 | 2016-04-10 | 2016-04-22 | 2 | 3 |
+-----------+------------+------------+--------+---------+
后,我在我的数据发送到前端:
function getGuestHistory(id, res){
dbHandler.query(`SELECT * FROM booking WHERE guestId='${id}';`, function(err, rows) {
res.end(JSON.stringify(!err ? rows : `error: ${err}`));
});
}
现在在前端,当我打印出来console.log(res)
我的反应是不同的:
[Object]
0: Object
bookingId: 3
endDate: "2016-04-21T21:00:00.000Z"
guestId: 3
roomId: 2
startDate: "2016-04-09T21:00:00.000Z"
看,startDate
和endDate
改变。例如,来自DB 2016-04-10
的startDate
现在是2016-04-09
。为什么日期发生变化,我该如何解决?
它从服务器的时区变为UTC。 – Barmar