www.ctrt.net > js两个日期相差天数

js两个日期相差天数

俺知道地主哥不是学js的啦不用强调的啦不过有异曲同工之妙的啦var d1=new Date('2010-01-01');var d2=new Date('2010-02-02');(d2-d1)/(24*60*60*1000)

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 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....

1.把开始时间和结束时间保存 var dateFrom = new Date(strFrom); var dateTo = new Date(strTo); 2.计算时间差 var diff = dateTo.valueOf() - dateFrom.valueOf(); 3.时间差转换为天数 var diff_day = parseInt(diff/(1000*60*60*24));

var date1=new Date(); //开始时间 var date2=new Date(); //结束时间 var date3=date2.getTime()-date1.getTime() //时间差的毫秒数 ------------------------------ //计算出相差天数 var days=Math.floor(date3/(24*3600*1000))

var date1 = new Date('2013/04/02 18:00')var date2 = new Date('2013/04/02 19:22:21')var s1 = date1.getTime(),s2 = date2.getTime();var total = (s2 - s1)/1000;var day = parseInt(total / (24*60*60));//计算整数天数var afterDay = tot...

//两个日期 var date1 = '2013-03-26'; var date2 = '2011-01-10'; // 拆分年月日 date1 = date1.split('-'); // 得到月数 date1 = parseInt(date1[0]) * 12 + parseInt(date1[1]); // 拆分年月日 date2 = date2.split('-'); // 得到月数 date2 ...

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...

// 给日期类对象添加日期差方法,返回日期与diff参数日期的时间差,单位为天Date.prototype.diff = function(date){ return (this.getTime() - date.getTime())/(24 * 60 * 60 * 1000);}// 构造两个日期,分别是系统时间和2013/04/08 12:43:45va...

var doubleFish = function (start, end) { var reg = /[^\d]/g; var a = new Date(start.replace(reg, "/")); var b = new Date(end.replace(reg, "/")); var result = {}; for(; a.getTime()

网站地图

All rights reserved Powered by www.ctrt.net

copyright ©right 2010-2021。
www.ctrt.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com