Study/Frontend
[Javascript] 특정 month의 마지막 날짜 구하는 법
안다희
2020. 3. 27. 03:17
728x90
const today = new Date();
const nextMonthFirstDate = new Date(today.getFullYear(), today.getMonth() + 1, 1);
const currentMonthLastDate = new Date(nextMonthFirstDate - 1); // 1일을 빼준다
const lastDate = currentMonthLastDate.getDate(); // 원하는 마지막 날짜를 얻었다!