In the project, I want to write down the current day and month like this:
Today is the 13th of September
When getting the current day, there is no error. But, when converting the current month number to the current month name, I get the error below:
Date.jsx:4 Uncaught RangeError: Maximum call stack size exceeded
My code in the Date component:
function Date() {
let date = new Date()
// console.log(dayDate.getDate())
const takeMonth = (month) => {
const monthName = date.setMonth(month - 1)
return monthName.toLocaleString("default", { month: "long" })
}
return <div> Date {takeMonth(3)}</div>
}
All answers are appreciated!