小程序获取日期 年月日
在小程序中,可以使用Date对象来获取当前的年、月和日
const now = new Date(); const year = now.getFullYear(); // 获取当前年份 const month = now.getMonth() + 1; // 获取当前月份,注意月份是从0开始的,因此需要加1 const day = now.getDate(); // 获取当前日期 console.log(`当前年份:${year}`); console.log(`当前月份:${month}`); console.log(`当前日期:${day}`);
###############################
QQ 3087438119

浙公网安备 33010602011771号