0

Trying converting the value vr 27.03.2020 to a Date object

<script>
  let date = new Date("vr 27.03.2020");
  console.log(date);
</script>

Result: Invalid Date

What is the best way convert the value to a Date object?

PS: vr is abbreviation from dutch vrijdag (=friday)

Tuxy
  • 91
  • 10
  • I'd say use a standard string representation – Guerric P Mar 23 '20 at 20:13
  • 1
    Get the digits, say using *match* or a *substring*, then pass them to the Date constructor. Remember to subtract 1 from the month. ;-) – RobG Mar 23 '20 at 20:14
  • You might also take a look at [*Why does Date.parse give incorrect results?*](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results) – RobG Mar 23 '20 at 20:17
  • 1
    Hi guys, thanks for all the answers. Do reseatch and i found when change the value to **vr 2020.03.27** then the result is: **Fri Mar 27 2020 00:00:00 GMT+0100 (Midden-Europese standaardtijd)** . This works correct, only, how change to this date-format (yy/mm/dd) in JS? – Tuxy Mar 23 '20 at 21:10

0 Answers0