본문 바로가기
Never Ending Study/JAVASCRIPT

두 일자 사이의 날짜들 가져오기

by 건방진참새 2019. 1. 24.

function getDates(startDate, endDate) {

  var dates = [],

      currentDate = startDate,

      addDays = function(days) {

        var date = new Date(this.valueOf());

        date.setDate(date.getDate() + days);

        return date;

      };

  while (currentDate <= endDate) {

    dates.push(currentDate);

    currentDate = addDays.call(currentDate, 1);

  }

  return dates;

};



참고: https://gist.github.com/miguelmota/7905510

'Never Ending Study > JAVASCRIPT' 카테고리의 다른 글

javascript 로 url param 가져오기  (0) 2019.03.06
js 이미지 미리보기  (0) 2019.01.30
CLOSE DIV ON CLICK OUTSIDE OF IT  (0) 2019.01.08
날짜 형식 및 세부적으로 가져오기  (0) 2018.12.27
ajax 통신 간소화  (0) 2018.12.10