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

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 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 computeDays(startTime, endTime) { var st=new Date(startTime.replace(/-/g,"\/")); var et=new Date(endTime.replace(/-/g,"\/")); return (et-st)/(24*60*60*1000); } function getDays() { alert(computeDays("2015-01-01","2016...

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

// 获取当前时间时间戳var currentTime = Date.now();// 获取指定时间时间戳// 注1:这里写的是2012年9月1日0时0分0秒// 注2:Javascript中月份是实际数字减1var targetTime = (new Date(2012, 8, 1, 0, 0, 0)).getTime();// 获取差值,如果指定...

//获取多久以前,比如1秒前、一分钟前、一天前,等等function getTimeFormat(startTime) { var startTimeMills = startTime.getTime(); var endTimeMills = new Date().getTime(); var diff = parseInt((endTimeMills - startTimeMills) / 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...

如果只是要这个功能 , 就不要跟日期类打交道了..直接算就好了 function getMonths(date1 , date2){ //用-分成数组 date1 = date1.split("-"); date2 = date2.split("-"); //获取年,月数 var year1 = parseInt(date1[0]) , month1 = parseInt(dat...

网站地图

All rights reserved Powered by www.ctrt.net

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