dayjs
dayjs copied to clipboard
dayjs('10-10').format('MM.DD') get 10.01 in iOS
Describe the bug When using dayjs('10-10').format('MM.DD') on iOS (Safari), the result is 10.01 instead of the expected 10.10.
Expected behavior The expected result should be 10.10 when formatting the date as MM.DD.
Information
- Day.js Version [e.g. v1.0.0]
- OS: [iOS]
- Browser [safari]
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]
It seems that Date behaves differently in Safari browser than in other browsers. I added exception handling code for cases where input is in MM-DD format.
For consistent results parsing anything other than ISO 8601 strings, you should use String + Format. https://day.js.org/docs/en/parse/string-format