function generateSerialNumber() { const now = new Date(); const year = now.getFullYear(); //得到年份 const month = now.getMonth() + 1; //得到月份 const date = now.getDate(); //得到日期 const hour = now.getHours(); //得到小时数 const minute = now.getMinutes(); //得到分钟数 const second = now.getSeconds(); //得到秒数 const time = now.getTime(); return `${year}${month}${date}${hour}${minute}${second}${time}`; } const res = generateSerialNumber(); console.log(res);