프론트엔드/Java Script, jQuery, AJAX
[자바스크립트] 두 날짜간 차이 구하기, 기간구하기
데르벨준
2014. 7. 4. 11:26
반응형
/* from = 20140101, to = 20140202*/
function(from, to, gapDay) {
if (from == null || to == null)
return true;
var newDateFrom = new Date(from.substring(0,4), from.substring(4,6), from.substring(6,8));
var newDateTo = new Date(to.substring(0,4), to.substring(4,6), to.substring(6,8));
var interval = (newDateTo - newDateFrom) / (1000 * 60 * 60 * 24);
if (interval > gapDay) {
alert('조회기간이 ' + gapDay + '일이 이내로 입력해주세요.');
return false;
}
return true;
}
반응형