new Date() 获取当前时间,如格式为 年-月-日,可以使用如下方法:
const date = new Date();
const current_date = date.getDate();
// 获取本 日
const current_month = date.getMonth() + 1;
// 获取本 月
const current_year = date.getFullYear();
// 获取本 年
console.log('-----------------------------------------------------');
console.log(current_year + '-' + current_month + '-' + current_date);
console.log('-----------------------------------------------------');
打印后: