JS简单的获取本地的年月日
2018-12-18 本文已影响0人
bryan_liu
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