js取当前时间年月日


 var now = new Date();

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

你可能感兴趣的:(JS,基础知识)