日期:2014-05-16 浏览次数:20376 次
function compareDate(sDateStr,localDateStr,hours)
{
var sDate = new Date(sDateStr);
var localDate = new Date(localDateStr);
if(isNaN(sDate))
{
alert(sDateStr+"日期格式不正确");
return ;
}
if(isNaN(localDate))
{
alert(localDateStr+"日期格式不正确");
return ;
}
var lastSeconds = hours * 3600000;
console.log(sDate.valueOf());
console.log(localDate.valueOf()+ lastSeconds);
return sDate.valueOf() >= (localDate.valueOf()+ lastSeconds)? true:false;
}
alert(compareDate("2013-1-12 19:00", "2013-1-12 10:00",10));
alert(compareDate("2013-1-12 20:00", "2013-1-12 10:00",10));