获取当前时间模块
function CurentTime(){ var now = new Date(); var year = now.getFullYear(); //年 var month = now.getMonth() + 1; //月 var day = now.getDate(); //日 var h = now.getHours(); //时 var m = now.getMinutes(); //分 var s = now.getSeconds(); //秒 var clock = year + "-"; if(month < 10) clock += "0"; clock += month + "-"; if(day < 10) clock += "0"; clock += day + " "; if(h < 10) clock += "0"; clock += h + ":"; if (m < 10) clock += '0'; clock += m + ":"; if (s < 10) clock += '0'; clock += s; return(clock); } setTimeout(()=>{ console.log(CurentTime()) },1000)