//시작일, 종료일 사이 일수 계산(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' 카테고리의 다른 글
| [thyemeleaf] get 방식 parameter값 붙이기 (0) | 2025.12.10 |
|---|---|
| [thyemeleaf] form 검색값 유지 (0) | 2025.11.24 |
| [mybatis] 검색(Oracle) (0) | 2025.11.24 |
| [mybatis] selectkey값 return(Oracle) (0) | 2025.11.24 |
| [springBoot] UrlResource 사용 시 경로 에러 (0) | 2025.11.24 |
댓글