Is there any way to get a localized format in DayJS plugin but without the day? I need to show in a calendar the month and year only but depending on the locale, the month can be on the first place or at the end.
I've checked in the docs (https://day.js.org/docs/en/display/format#localized-formats) but it seems there is nothing with year and month only.
dayjs().format("LL") // December 7, 2022
// what I would like to get: December 2022 or 2022 December (depending on the locale)
Thanks in advance
I end up using a regex to delete the part I didn't want.
dayjs().format("LL").replace(/\b\s*\d{1,2}\s*\b/g, '');
DEMO:
["December 7, 2022", "7 Décembre 2022"].map(date => console.log(date.replaceAll(/\b\s*\d{1,2}\s*\b/g, '')));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With