Javascript日期格式话

//对获取系统日期进行格式化
function formatDate()
{
   var DateIn = new Date();
    var Year = 0;  
    var Month = 0;  
    var Day = 0;  
             
   var CurrentDate = "";  
              
   //初始化时间  
     Year  = DateIn.getYear();  
    Month  = DateIn.getMonth()+1;  
    Day  = DateIn.getDate();  
              
   CurrentDate = Year + "-";  
    if (Month >= 10 ){  
        CurrentDate = CurrentDate + Month + "-";  
   } else{  
        CurrentDate = CurrentDate + "0" + Month + "-";  
    }  
    if (Day >= 10 ){  
        CurrentDate = CurrentDate + Day ;  
    } else{  
        CurrentDate = CurrentDate + "0" + Day ;  
    }   
   return  CurrentDate;
  }
//验证整改时间
function saveMultiRecord() {
//系统当前日期
         var date1 = this.formatDate();
         var reg=/[^0-9]/g ;
         var dqsj = date1.replace(reg,"");
         for(var rowIndex = 0; rowIndex < mygrid.getRowsNum();rowIndex ++ ){
          var  date2 = mygrid.cells2(rowIndex ,4).getValue();  //获取整改时间
            var zgsj = date2.replace(reg,"");
           alert(dqsj+"************"+zgsj);                     
          if( parseInt(dqsj) > parseInt(zgsj) ){
                 new iMsgBox("要求整改时间不能早于当前时间", "填写提示").showAlert();
                 return false ;
  }
}
saveMultiRecord_target();
}

你可能感兴趣的:(JavaScript)