Get long locale date format without momentjs

880 views Asked by At

I have been migrating from moment.js to date-fns and was stuck at a point where couldn't find an alternative for

moment.localeData().longDateFormat("LL");

For more information :

localeData = moment.localeData()
localeData.longDateFormat()

returns

{
  LT : 'HH:mm',
  LTS : 'HH:mm:ss',
  L : 'DD/MM/YYYY',
  LL : 'D MMMM YYYY',
  LLL : 'D MMMM YYYY HH:mm',
  LLLL : 'dddd, D MMMM YYYY HH:mm'
}

In general , is there any alternative for this function in date-fns or vanilla js ?

1

There are 1 answers

0
Aryan Shridhar On

After digging for a while , The PPP format within date-fns , can be used . Other solution for it can be to use Intl.DateTimeFormat with the suitable parameters as mentioned in the docs .