js 当前日期格式化 YYYY-MM-DD

var now = new Date();
var time = now.getFullYear() + "-" +((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+"-"+(now.getDate()<10?"0":"")+now.getDate();

原文地址:https://www.cnblogs.com/-swz/p/15079970.html