export default function BudgetDate() {
const month = month.toLocaleString("de-de", { month: "long" });
const year = year.getFullYear();
const day = day.toLocaleString("de-de", { day: "2-digit" });
return (
<div className="expense-date">
<div className="expense-date__month"></div>
<div className="expense-date__year"></div>
<div className="expense-date__day"></div>
</div>
);
}
This is a component called BudgetDate im coding. It' going to be nested in another component called BudgetBar.
import styles from "./BudgetBar.module.css";
export default function Budgetbar() {
return (
<div className={styles.wrapperDiv}>
<button className={styles.basicBar}>
<div className={styles.date}>
<div>Februar</div>
<div>2022</div>
<div>05</div>
</div>
<div className={styles.item}>Sony Playstation</div>
<div className={styles.amount}>500 Euro</div>
</button>
</div>
);
}
My goal is to replace
<div className={styles.date}>
<div>Februar</div>
<div>2022</div>
<div>05</div>
</div>
with simply
<BudgetDate />
in order to use correctly formatted date.
However, my problem is, that i don't know how to write code inside the BudgetDate component. I want do hardcode the Year, the date and the month between the divs inside the BudgetDate and use the .toLocaleString methods. What is a way to archive that?