Javascript program to Print Present Date
Below program shows you how to print Present Date in the format yyyy-mm-dd.
function getDate() {
var today = new Date();
var date = String(today.getDate()).padStart(2, '0');
var month = String(today.getMonth() + 1).padStart(2, '0');
var year = today.getFullYear();
currentDay = year+ '-' + month + '-' + date;
console.log(currentDay);
}
getDate();
Output:
2021-07-17
Try it Online here https://onecompiler.com/javascript/3x5qc6g94