0

I'm trying to read a file using csvtojson module. Date field is getting read as "05-23-2020" & next date is "23-03-2020" . Format which I should use is dd-mm-yyyy. But here in the backend if I try to convert the follwing date "23-03-2020" using

new Date("23-03-2020)

I'm getting as invalid date. But for this date "05-23-2020" , I can get the value.

How can I solve this issue?. New Date will only accept the date string in mm-dd-yyyy format. Can anyone please help me with this?

sai
  • 487
  • 1
  • 7
  • 16
  • It is good to have consistent dates in csv to avoid confusion and have a definite logic. You can use libraries like https://github.com/wanasit/chrono to parse diff format of date. But how would you classify a date like `03-03-2020` treat it as `mm-dd-yyyy` or `dd-mm-yyyy` ? Which is why you can define a consistent date format to be provided. – Panther May 23 '20 at 02:56
  • @Panther Yeah. In my case customer wants to follow dd-mm-yyyy but here thta way is not working. Could you please suggest me? – sai May 23 '20 at 03:01

0 Answers0