//两个时间相差天数 兼容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;
1--Java 分析:调用java中Calendar类 int days(Date date1,Date date2){ Calendar cal = new Calendar.getInstance(); cal.setTime(date1); int time1 = cal.get(Calendar.DAY_OF_YEAR); cal.setTime(date2); int time2 = cal.get(Calendar.DAY_OF_YEAR); //long days = Math.a
var start=1491789600000;//2017-4-10 10:00 var end=1494381600000;//2017-5-10 10:00 var utc=end-start; utc/(24*60*60*1000);// 天 utc/(60*60*1000);//小时 utc/(60*1000); // 分