标签:
用javascript返回两个时间差,精确到秒:
Date.diff = function(a,b)
{
if(a instanceof Date && b.instanceof Date)
{
return Math.round((a.getTime() - b.getTime()) / 1000);
}
else
{
throw new Error("Argument Exception");
}
}
参考:(new Date(Date String) - new Date(OldDate String) )/1000
时间格式转换为毫秒数:
EX:Date.parse("01/01/2011 10:10:10")
EX:
var timeGet = $("#J_date_1").attr("value");
var _timeGet = timeGet.split("-");
var timeGetFix = Date.parse(_timeGet[0] + "/" + _timeGet[1] + "/" + _timeGet[2] + " " + $("#gettime").attr("value"));
var timeRet = $("#J_date_2").attr("value");
var _timeRet = timeGet.split("-");
var timeRetFix = Date.parse(_timeRet[0] + "/" + _timeRet[1] + "/" + _timeRet[2] + " " + $("#rettime").attr("value")) + 86400000;
if ((timeRetFix - timeGetFix) / 3600000 < 24)
{
$(".step1-box .ts-box").show();
}
else
{
$(".step1-box .ts-box").hide();
}
标签:
原文地址:http://www.cnblogs.com/mixzo/p/4213661.html