JS脚本:
function checkDateIsEdited(createDate) { var compareDate = createDate.replace("-","/"); //替换字符,变成标准格式 var nowDate = new Date(); var diffTime = nowDate.getTime()-compareDate.getTime() //时间差的毫秒数 var diffDays =Math.floor(diffTime/(1000*60*60*24)) if(diffDays < 60){ return true; }else{ return false; } }
Java代码:
private boolean isAllowEdited(Object object) { if(null != object){ Date nowDate = new Date(); long diffTime = nowDate.getTime() - ((Date) object).getTime(); long diffDays = diffTime / (1000 * 60 * 60 * 24); if(diffDays<=60){ return true; } } return false; }