본문 바로가기

개발일지

TIL 2022.05.16

자바스크립트는 이상하게 월이 0부터 시작해서

+1을 해야 한다

 
`${curDate.getMonth() + 1}`

~년 ~월은 이렇게

`${curDate.getFullYear()}${curDate.getMonth() + 1}`
 
const increaseMonth = () => {
setCurDate(
new Date(curDate.getFullYear(), curDate.getMonth() + 1, curDate.getDate())
);
};
 
const decreaseMonth = () => {
setCurDate(
new Date(curDate.getFullYear(), curDate.getMonth() - 1, curDate.getDate())
);
};

#100daysofcode day31

'개발일지' 카테고리의 다른 글

TIL 2022.05.19  (0) 2022.05.19
TIL 2022.05.18  (0) 2022.05.18
TIL 2022.05.15  (0) 2022.05.15
TIL 2022.05.13  (0) 2022.05.13
TIL 2022.05.12  (0) 2022.05.12