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

 

posted @ 2021-09-29 08:55  虚无——缥缈  阅读(69)  评论(0编辑  收藏  举报