'How to parse date string with '0' day to Date in moment.js?

I have a string representation of date in TypeScript like this: '05-00-2018'. And would like to transform it to JavaScript Date object using momentjs. I tried this:

new Date(moment.utc('05-00-2018', 'MM-DD-YYYY').format('MM-DD-YY'))

But it gives me 'Invalid Date'. Could anyone advice me?



Solution 1:[1]

So I managed to get it working with the following solution:

moment.utc('05-00-2018', 'MM/00/YYYY').startOf('day').toDate()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SimonD