본문 바로가기
▶ Front-End/Javascript

Start to Last Date

by 오늘도 코딩 2023. 11. 14.
728x90
반응형

Date 타입의 시작 날짜부터 종료 날짜까지 날짜들을 구하는 메소드

*자세한 설명 생략

 

 

/**
 * Start to Last Date
 * @param {*} startDate(Date)
 * @param {*} lastDate(Date)
 * @returns YYYY-MM-dd
 */
function getDatesStartToLast(startDate, lastDate) {
    if (!(startDate instanceof Date && lastDate instanceof Date)) return "Not Date Object";
    var result = [];
    var curDate = startDate;
    while (curDate <= lastDate) {
        result.push(getFormatDate2(curDate));
        curDate.setDate(curDate.getDate() + 1);
    }
    return result;
}

 

 

▷ 관련 글

 

Date Formater

Date 타입을 원하는 Format으로 변경하는 메소드 *자세한 설명 생략 /** * Date Formater * * @param {*} date * @returns YYYYMMdd */ function getFormatDate(date) { const YYYY = String(date.getFullYear()) const MM = String((date.getMonth() +

coding-today.tistory.com

 

 

728x90
728x90

'▶ Front-End > Javascript' 카테고리의 다른 글

Date Formater  (0) 2023.11.14
Null Check  (0) 2023.11.14

댓글