标签:
var date3=date2.getTime()-date1.getTime() //时间差的毫秒数
------------------------------
//计算出小时数
function getDays() {
var txtDate = document.getElementById("txtDate");
var txtDate1 = document.getElementById("txtDate1");
var span_day = document.getElementById("span_day");
var StartDate = txtDate.value.split(‘ ‘)[0];
var StartTime = txtDate.value.split(‘ ‘)[1];
var EndDate = txtDate1.value.split(‘ ‘)[0];
var EndTime = txtDate1.value.split(‘ ‘)[1];
if (ByTrim(StartDate) != ‘‘ && ByTrim(EndDate) != ‘‘) {
var date = new Date(StartDate.split(‘-‘)[0], StartDate.split(‘-‘)[1], StartDate.split(‘-‘)[2], StartTime.split(‘:‘)[0], StartTime.split(‘:‘)[1]);
var date1 = new Date(EndDate.split(‘-‘)[0], EndDate.split(‘-‘)[1], EndDate.split(‘-‘)[2], EndTime.split(‘:‘)[0], EndTime.split(‘:‘)[1]);
var day = ((date1.getTime() - date.getTime()) / (24 * 3600)) / 1000;
span_day.innerText = parseFloat(day).toFixed(2);
}
}
标签:
原文地址:http://www.cnblogs.com/panmy/p/5550492.html