更新时间:2023-01-30 08:40:15
试试这个
var date1 = new 日期( 31/08/2014);
var date2 = new 日期( 28/08/2014);
var timeDiff = 数学 .abs(date2.getTime() - date1.getTime() );
var diffDays = 数学 .ceil(timeDiff /( 1000 * 3600 * 24 ));
alert(diffDays);
试试这个如何计算月和日 [ ^ ]
首先得到你的日子日期然后区别于此。var SecondDate = 新 日期(2014年8月31日);
var FirstDate = new 日期(28 - 8 - 2014);
var SecondDateDay = SecondDate.getDay();
var FirstDateDay = FirstDate.getDay();
var DayDif = SecondDateDay - FirstDateDay
alert(DayDif);
I Want like these
1st Date=31-Aug-2014(dd-MMM-yyyy)
2nd Date=28-Aug-2014(dd-MMM-yyyy)
DayDiff= (2nd Date - 1st Date)
Ans = 3
Try use thisvar date1 = new Date("31/08/2014"); var date2 = new Date("28/08/2014"); var timeDiff = Math.abs(date2.getTime() - date1.getTime()); var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); alert(diffDays);
try this How to calucate months and Days[^]
First get Days from Your Dates and then take difference of that.var SecondDate = new Date(31-Aug-2014); var FirstDate = new Date(28-Aug-2014); var SecondDateDay = SecondDate.getDay(); var FirstDateDay = FirstDate.getDay(); var DayDif = SecondDateDay - FirstDateDay alert(DayDif);