var d = new Date;
var year = d.getFullYear();
var month = (d.getMonth() + 1) >=10? (d.getMonth() + 1) : "0" + (d.getMonth() + 1);
var date = d.getDate() >=10 ? d.getDate() : "0" + d.getDate();
var tempDate = year + "-" + month + "-" + date;
console.log(tempDate) //输出格式:xxxx-xx-xx
网友评论