const timestamp = (time, pattern) => { let getDate = new Date(time); let year = getDate.getFullYear(); let minute = getDate.getMinutes(); let second = getDate.getSeconds(); let month = getDate.getMonth() + 1; let day = getDate.getDate(); const addZero = (num) => { return num < 10 ? `0${num}` : num; }; const dispose = { date: `${addZero(month)}月${addZero(day)}日`, // 月 日 colon: addZero(minute) + ":" + addZero(second), // : point: `${year}.${addZero(month)}.${addZero(day)}`, // . line: `${year}-${addZero(month)}-${addZero(day)}`, // - }; return dispose[pattern] || {}; };