//시작일, 종료일 사이 일수 계산(yyyymmdd 형식)
function calDiffDays(startDate, endDate) {
//시작일
const strDt = new Date(startDate.substring(0,4), startDate.substring(4,6), startDate.substring(6,8));
//종료일
const endDt = new Date(endDate.substring(0,4), endDate.substring(4,6), endDate.substring(6,8));
//일수 차이(절대값)
let diffDays = Math.abs(endDt.getTime() - strDt.getTime());
//하루(밀리세컨드)로 나눈 뒤 반올림
return Math.floor(diffDays / (1000 * 60 * 60 * 24));
}
자바스크립트 날짜간의 차이 구하기 ( yyyyMMdd 형식 )
자바스크립트 날짜간의 차이 구하기 ( yyyyMMdd 형식 ) javascript에서 두날짜간의 차이 일수를 구해야할 일이 있을때 사용하면 된다. function betweenDay(firstDate, secondDate) { var firstDateObj = new Date(firstDate.sub...
www.appletong.com
'IT > development' 카테고리의 다른 글
[mybatis] selectkey값 return(Oracle) (0) | 2023.05.06 |
---|---|
[mybatis] 검색(Oracle) (0) | 2023.05.06 |
[thyemeleaf] form 검색값 유지 (0) | 2023.04.26 |
[thyemeleaf] get 방식 parameter값 붙이기 (0) | 2023.04.26 |
[thyemeleaf] select option값 list loop (0) | 2023.04.26 |
댓글