var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
month = (month < 10 ? ‘0‘ : ‘‘) + month;
var day = date.getDate();
day = (day < 10 ? ‘0‘ : ‘‘) + day;
var nowTime = year + ‘-‘ + month + ‘-‘ + day;
console.info(‘当前时间为:‘+nowTime);
时间: 2024-10-19 14:47:08