最佳答案
我相信很多人都问过这个问题,但是当我检查答案的时候,在我看来,我发现的答案是错误的
var startDate = new Date(Date.parse(startdate));
//The start date is right lets say it is 'Mon Jun 30 2014 00:00:00'
var endDate = new Date(startDate.getDate() + 1);
// the enddate in the console will be 'Wed Dec 31 1969 18:00:00' and that's wrong it should be 1 july
我知道 .getDate()
从1-31返回,但是浏览器或 javascript 是否只增加了一天而没有更新月份和年份?
在这种情况下,我应该写一个算法来处理这个问题吗? 还是有其他的方法?