class Times { static bjTime(dateForm) { if (dateForm === "") { //解决deteForm为空传1970-01-01 00:00:00 return ""; } else { var dateee = new Date(dateForm).toJSON(); var date = new Date(+new Date(dateee) + 8 * 3600 * 1000) .toISOString() .replace(/T/g, " ") .replace(/\.[\d]{3}Z/, ""); return date; } } static utcTime(dateForm) { if (dateForm === "") { //解决deteForm为空传1970-01-01 00:00:00 return ""; } else { var dateee = new Date(dateForm).toJSON(); var date = new Date(+new Date(dateee)) .toISOString() .replace(/T/g, " ") .replace(/\.[\d]{3}Z/, ""); return date; } } static times() { const date = new Date(); const y = date.getFullYear(); const M = String(date.getMonth() + 1).padStart(2, '0'); const d = String(date.getDate()).padStart(2, '0'); const h = String(date.getHours()).padStart(2, '0'); const m = String(date.getMinutes()).padStart(2, '0'); const s = String(date.getSeconds()).padStart(2, '0'); return [ `${y}-${M}-${d} ${h}:${m}`, // 格式:YYYY-MM-DD HH:mm `${y}-${M}-${d} ${h}:${m}:${s}`, // 格式:YYYY-MM-DD HH:mm:ss `${y}-${M}-${d}`, // 格式:YYYY-MM-DD `${m}`, // 分钟格式:mm `${h}`, // 小时格式:HH `${d}` // 日期格式:DD ]; } } module.exports = Times;