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

//两个日期 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 monthDiff(d1, d2) { var months; months = (d2.getFullYear() - d1.getFullYear()) * 12; months -= d1.getMonth() + 1; months += d2.getMonth(); return months

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

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()

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 start = $("#startDate").val();var end = $("#endDate").val();var date1 = new Date(start.replace(/[^\/\d]+/g,"/")+",0:0:0");var date2 = new Date(end.replace(/[^\/\d]+/g,"/")+",0:0:0");date1.setMonth(date1.getMonth() + 2);if (...

不知道具体文本框,只能写个伪代码了: var date1;//时间1 var date2;//时间2 var day;//天数 day=Math.(Math.abs(date1.getTime()-date2.getTime())/(1000*60*60*24))

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

网站地图

All rights reserved Powered by www.ctrt.net

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