If you want to put date information as string like "2020-07-30" to date in javascript, bingo! - it works correctly.
ISO 8601 is the international standard for the representation of dates and times. The ISO 8601 syntax (YYYY-MM-DD) is also the preferred JavaScript date format:
var d = new Date("2020-07-30")
If you want to get its element value like FullYear, Month, Date, Hours, and etc. You can simply get it like below.
var d = new Date(); document.getElementById("demo").innerHTML += d.getFullYear(); // Get the year as a four digit number (yyyy) document.getElementById("demo").innerHTML += d.getMonth(); // Get the month as a number (0-11) document.getElementById("demo").innerHTML += d.getDate(); // Get the day as a number (1-31) document.getElementById("demo").innerHTML += d.getHours(); // Get the hour (0-23) document.getElementById("demo").innerHTML += d.getMinutes(); // Get the minute (0-59) document.getElementById("demo").innerHTML += d.getSeconds(); // Get the second (0-59) document.getElementById("demo").innerHTML += d.getMilliseconds(); // Get the millisecond (0-999) document.getElementById("demo").innerHTML += d.getTime(); // Get the time (milliseconds since January 1, 1970) document.getElementById("demo").innerHTML += d.getDay(); // Get the weekday as a number (0-6) document.getElementById("demo").innerHTML += Date.now(); // Get the time. ECMAScript 5.
If you want to convert it to string in Javascript
var d = new Date(); alert( d.toString());