iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
47.1k stars 2.31k forks source link

Feature request: More localized formats #2174

Open Pacn91 opened 1 year ago

Pacn91 commented 1 year ago

I'm trying 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 isn't an option 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) 

What I want is possible to do with the current version of DayJS? If so could you tell me how please? If not could you implement more localized formats (like a month and year format only)?

Thanks in advance

Information

mstykow commented 1 year ago

The few options for localized dates that exist today are really a show-stopper for us. The system is simply too rigid.

Without more flexibility here, we are now forced to use date-fns instead. https://date-fns.org/v2.30.0/docs/I18n

davor-bauk-sh commented 7 months ago

Agreed. There is currently no way to format a date without the year (eg. "Aug 18"). It would also be great if one could format a date range in a flexible manner (eg. "Aug 18–20", "Aug 18–Sep 3", "Aug 18, 2024–Jan 7, 2025", depending on whether the range spans months or years, etc.)