获取当前年月日2020-09-30格式

  获取格式为yy-mm-dd的时间

var now=new Date();
function getTimeFun(now){
   let year = now.getFullYear(); 
   let month = ((now.getMonth()+1)<10?"0":"") + (now.getMonth()+1);
   let day = (now.getDate()<10?"0":"")+now.getDate();
   time=year+'-'+month+"-"+day;
   console.log(time)
   return time;
};
getTimeFun(now);
原文地址:https://www.cnblogs.com/xuwupiaomiao/p/15351128.html