on
React) 날짜 연산( 더하기 뺴기)
React) 날짜 연산( 더하기 뺴기)
15일, 30일, 90일, 180일 나눠서 계산
결과화면
const [startDate, setStartDate] = useState(new Date()) const [endDate, setsEndDate] = useState(new Date()) // 날짜 연산 함수 const _handle15day = () =>{ const today = new Date(); const newDay = new Date(); return setStartDate(newDay.setDate(today.getDate() - 15 )) } const _handle30day = () =>{ const today = new Date(); const newDay = new Date(); return setStartDate(newDay.setDate(today.getDate() - 30 )) } const _handle90day = () =>{ const today = new Date(); const newDay = new Date(); return setStartDate(newDay.setDate(today.getDate() - 90 )) } const _handle180day = () =>{ const today = new Date(); const newDay = new Date(); return setStartDate(newDay.setDate(today.getDate() - 180 )) } 15일 1개월 3개월 6개월 setStartDate(date)} /> ~ setEndDate(date)} />
참고: https://7942yongdae.tistory.com/40
from http://developer-trier.tistory.com/473 by ccl(A) rewrite - 2021-12-31 09:27:27