function remove(id,bid,s_hour,e_hour){
if(这里帮我写一个 如果现在服务器的时间 大于 (e_hour的时间+10H) ){
就alert("禁止删除");
比如  e_hour传进来的参数是10:00  那只要在20:00之前 就不谈alert 如果20:00之后就弹出个禁止操作
}
else{
......
}

解决方案 »

  1.   

    时间最好是yyyy-mm-dd hh:nn 格式,这样可以避免跨天的问题//算相差小时,h1,h2格式yyyy-mm-dd hh:nn
    function hourDiff(h1,h2){
      return ( Date.parse(h2)-Date.parse(h1))/36E5>>0
    }
    if( hourDiff( s_hour,e_hour) <10 ){
     ....
    }else{
    ....
    }
      

  2.   

    不知道是否满足要求
    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));
      

  3.   

    getTime转换成格林威治时间比啊