(1)获取两个时间相差天数(没有上午下午区分) var d1=ABS_DATESTRING(FStartTime,'yyyy/MM/dd'); var d2=ABS_DATESTRING(FEndTime,'yyyy/MM/dd'); var date1= new Date(d1); var date2=new Date(d2); var time=date2.getTime()-date1.getTime(); var day=time/(1000*60*60*24);day (2)求历时几小
//两个时间相差天数 兼容firefox chrome var days = function(startDate) { var sdate = new Date(startDate.replace(/-/g, "/")); var now = new Date(); var days = now.getTime() - sdate.getTime(); var day = parseInt(days / (1000 * 60 * 60 * 24)); return day;
var stime = new Date('2016-03-14'); //开始时间 var etime = new Date('2016-03-20'); //结束时间 var times = etime.getTime()-stime.getTime(); //时间差的毫秒数 //计算出相差天数 var days=Math.floor(times/(86400*1000));