0

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.

Coder-Meca
  • 401
  • 1
  • 3
  • 13

1 Answers1

2

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')
Chromegear
  • 36
  • 3