I am trying to use the format method to display a date in a specific format. But resulting string has a month out of date. Here is my code:
const d = format(new Date('2018-02-19'), 'MM/DD/YYYY');
this gives me: 02/50/2018
I am doing something wrong there ?
Since 8th alpha, the correct token for day of month is dd (lowercase) and the correct token for year is yyyy (also lowercase). See: https://date-fns.org/v2.0.0-alpha.10/docs/format
So, it should be actually 'MM/dd/yyyy'
My bad, thanks!
Most helpful comment
Since 8th alpha, the correct token for day of month is
dd(lowercase) and the correct token for year isyyyy(also lowercase). See: https://date-fns.org/v2.0.0-alpha.10/docs/format