标签:判断时间是否相等 comparedate 判断时间是否在范围内 datetimecomper javascript
//判断时间是否相等 function compareDate(date1, date2) { //相等 if (date1 == date2) { return true; } var startTime = date1; var start = new Date(startTime.replace(/-/g, "/")); var endTime = date2; var end = new Date(endTime.replace(/-/g, "/")); if (end != start) { return false; } return true; }
//判断时间是否在范围内 function datetimeComper(year, month, day, currtime) { //var curr = "09:00:00"; var begin = "09:00:00"; var end = "16:00:00"; var currd = new Date(year, month, day, currtime.split(":")[0], currtime.split(":")[1], currtime.split(":")[2]); var begind = new Date(year, month, day, begin.split(":")[0], begin.split(":")[1], begin.split(":")[2]); var endd = new Date(year, month, day, end.split(":")[0], end.split(":")[1], end.split(":")[2]); if (currd >= begind && currd <= endd) { return true; } else { return false; } }
标签:判断时间是否相等 comparedate 判断时间是否在范围内 datetimecomper javascript
原文地址:http://blog.csdn.net/pengzhen8805/article/details/39373955