0

When I pick the value from the date picker input its in this format (Tue Mar 24 2020 17:00:00 GMT-0800(PST) I need to convert it to (MM-DD-YYYY)

Here is the part from my code where I get the value of the date

Reportinfo.ProjectDate = document.getElementById("date").value;

Any Ideas ? I didn't know how to implement

"toLocaleDateString()"  
Aboude
  • 149
  • 2
  • 12

1 Answers1

2

You can use momentjs and format the string like this:

moment(date).format('MM-DD-YYYY');

Or if that's not an option, you can use Date object and use this solution.

technophyle
  • 7,972
  • 6
  • 29
  • 50