λ°μν
Intro
JavaScript μμ νμ¬ μκ°μ κΈ°μ€μΌλ‘ νλ¬ μ /ν λ μ§λ₯Ό ꡬνλ λ°©λ²μ λν΄ μμ보λλ‘ νκ² μ΅λλ€.
How to solve the problem
let now = new Date(); // νμ¬ λ μ§ λ° μκ°
console.log("νμ¬ : ", now); // νμ¬ : Fri Sep 30 2022 11:05:32 GMT+0900 (νκ΅ νμ€μ)
let oneMonthAgo = new Date(now.setMonth(now.getMonth() - 1)); // νλ¬ μ
console.log("νλ¬ μ : ", oneMonthAgo); // νλ¬ μ : Tue Aug 30 2022 11:05:32 GMT+0900 (νκ΅ νμ€μ)
let now = new Date(); // νμ¬ λ μ§ λ° μκ°
console.log("νμ¬ : ", now);
let oneMonthLater = new Date(now.setMonth(now.getMonth() + 1)); // νλ¬ ν
console.log("νλ¬ ν : ", oneMonthLater);
λ°μν