为什么以下代码会导致 minDate 为零毫秒?
maxDate = new Date(2013,0,1,0,0,1,200);
minDate = new Date(maxDate.getTime());
我正在 Chrome 中查看此内容是否有影响?
最佳答案
minDate
的毫秒数不为零。毫秒位于 maxDate
中并进入 minDate
:
maxDate = new Date(2013,0,1,0,0,1,200);
console.log(maxDate.getMilliseconds());
minDate = new Date(maxDate.getTime());
console.log(minDate.getMilliseconds());
输出:
200
200
关于javascript - 为什么从 Javascript 中现有的 Date() 对象创建一个新的 Date() 对象不保留毫秒字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14946786/