【发布时间】:2016-05-11 11:25:47
【问题描述】:
我正在处理一个 NodeJS 项目,但我得到了错误的日期值。而且我不明白我做错了什么。
var d = new Date(results[1].timestamp);
console.log(results[1].timestamp); // 2016-05-10T13:29:47 <- this is right (stored at my DataBase)
console.log(d.getDate()); //10
console.log(d.getFullYear()); //2016
console.log(d.getMonth()); //4
console.log(d.getDay()); //2
console.log(d.getHours()); //15
console.log(d.getMinutes()); //29
console.log(d.getSeconds()); //47
所以月、日和小时是错误的。 我在我的 Mac 上的 google chrome 中看到了这些结果
感谢您的帮助
【问题讨论】:
-
您是否阅读了 getDay 和 getMonth 的文档?我认为你没有...
标签: javascript node.js date