Reputation: 409
I have the following code in my application :
moment(dateD, 'YYYY-MM-DD').format('DD/MM/YYYY')
The dateD
is like this 2020-05-30 00:00:00.0
i want to parse it to this Format DD/MM/YYYY
but the problem my code returns Invalid Date.
Upvotes: 0
Views: 2332
Reputation: 36
2020-05-30 00:00:00.0
can't be parsed with the format string YYYY-MM-DD
(the time is missing).
Simplest solution for your case would be:
moment(dateD.split(" ")[0], 'YYYY-MM-DD').format('DD/MM/YYYY')
Upvotes: 2