llgd.net
当前位置:首页 >> JS 计算两个日期之间相差多少天 >>

JS 计算两个日期之间相差多少天

function getTime2Time($time1, $time2){var time1 = arguments[0], time2 = arguments[1];time1 = Date.parse(time1)/1000;time2 = Date.parse(time2)/1000;var time_ = time1 - time2;return (time_/(3600*24));}document.write(getTime2Time(...

function getTime2Time($time1, $time2) { var time1 = arguments[0], time2 = arguments[1]; time1 = Date.parse(time1)/1000; time2 = Date.parse(time2)/1000; var time_ = time1 - time2; return (time_/(3600*24)); } document.write(getTi...

function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2002-12-18格式 var aDate, oDate1, oDate2, iDays aDate = sDate1.split("-") oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式 aDate = sDate2....

function monthDiff(d1, d2) { var months; months = (d2.getFullYear() - d1.getFullYear()) * 12; months -= d1.getMonth() + 1; months += d2.getMonth(); return months

var time = date2.getTime() - date1.getTime() ; //日期的long型值之差 两个日期相差 Math.floor(time/(24*60*60*1000)) 天

//+--------------------------------------------------- //| 求两个时间的天数差 日期格式为 YYYY-MM-dd //+--------------------------------------------------- function daysBetween(DateOne,DateTwo) { var OneMonth = DateOne.substring...

将两个日期转换成毫秒,然后相减,再计算出天数 var date1 = new Date('2016/12/31').getTime(), date2 = new Date().getTime(); var diff = date2 - date1; //相差的毫秒数 var day = diff / 1000; //相差秒数 day = day / 60; //相差分钟数 da...

相差的毫秒数 / 1000 / 60 / 60 /24

function compare(start,end){ start =start.getTime(); end =end.getTime(); var time =0 if(start>end){ time =start-end; }else{ time =end-start; } return Math.floor(time/86400000) } 参数是时间格式;只取天数,不满一天不算

function getTime2Time($time1, $time2) { var time1 = arguments[0], time2 = arguments[1]; time1 = Date.parse(time1)/1000; time2 = Date.parse(time2)/1000; var time_ = time1 - time2; return (time_/(3600*24)); } document.write(getTi...

网站首页 | 网站地图
All rights reserved Powered by www.llgd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com