获取当前年月日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);

 

上一篇:兔子生兔子问题


下一篇:微信小程序设置年月日选择器