0

I have a string being returned from a sql database that looks like this

Mon Jan 01 1753 12:00:00 GMT-0517 (Eastern Standard Time)

How can I format that string to 01-01-1753 and compare it against other dates like 01-01-2010?

At the very least how would I format the date, I should be able to go from there with what I need to do

Chris
  • 2,953
  • 10
  • 48
  • 118
  • Duplicated question. Answer is here: https://stackoverflow.com/questions/2035699/how-to-convert-a-full-date-to-a-short-date-in-javascript – MonneratRJ Mar 26 '19 at 17:00
  • `new Date(yourString)` will work as expected. – Jonas Wilms Mar 26 '19 at 17:13
  • @JonasWilms, I tried as you mentioned, let retDate = "Mon Jan 01 1753 12:00:00 GMT-0517 (Eastern Standard Time)"; let myDate = new Date(retDate); console.log(myDate); It just shows the same string – Chris Mar 26 '19 at 17:29
  • 1
    @chris yes, which means that new Date parsed it correctly, and then showed it to you as if it would be a string (it isn't) – Jonas Wilms Mar 26 '19 at 17:31
  • I went through the solutions in the How to format a JavaScript date and got one that worked – Chris Mar 26 '19 at 17:35

0 Answers0