I'm doing a React JS Course. I want to render the day and date by using props and toLocaleString method. But the app just crashes. Here's my code
function ExpenseDate(props) {
const month = props.date.toLocaleString("en-US", { month: "long" });
const day = props.date.toLocaleString("en-US", { day: "2-digit" });
const year = props.date.getFullYear();
return (
<div>
<div>{month}</div>
<div>{year}</div>
<div>{day}</div>
</div>
);
}
export default ExpenseDate;
When I export & use that component & refresh the server. The server shows this: Undefined (reading 'toLocaleString')
Please help. I'm in a rush!