Moment.js quirks on iOS

March 4, 2020

There is this weird issue with Moment.js where if you only provide a month string it doesn't know how to format it.


// Should output "January"
moment('01').format('MMMM');

// But instead outputs "December"

I didn't look into it too deeply to figure out why it's not working, but a temporary workaround is to just add the current year to the month.

For example:


// This works and outputs: 'January'
moment('2020-01').format('MMMM');

Anyway, it was interesting to me because it works fine on desktop, just not iOS...weird.