How to change date format in react js


0

I am trying to read a CSV file. The date in the file in a format - 'DD-MMM-YY'. When I am trying to read this, I am getting an invalid date error. 01-Apr-20 - how do we read this in react?

Thank you!

1.3K views

3 Answers

0
Volkan Usta Volkan Usta

This is a useless question.

0
Volkan Usta Volkan Usta

what a stupid question

0
John Szymanski John Szymanski

If you can afford to use an external library, you can use moment.js.

Then, to read these dates, simply use the following line:

moment('01-Apr-20', 'DD-MMM-YY')

which returns a moment object (basically like a Date-object), with a lot of functionality.

Your Answer

Signin to post your answer