<pre><code>function curDateTime() {
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth() + 1;
var date = d.getDate();
var day = d.getDay();
var curDateTime = year;
if (month > 9)
curDateTime = curDateTime + "-" + month;
else
curDateTime = curDateTime + "-0" + month;
if (date > 9)
curDateTime = curDateTime + "-" + date;
else
curDateTime = curDateTime + "-0" + date;
return curDateTime;
}
curDateTime()
"2019-03-21"