function formatTime(fmt, date1) { let ret; let date = new Date(date1); const opt = { "Y+": date.getFullYear().toString(),   // 年 "m+": (date.getMonth() + 1).toString(),   // 月 "d+": date.getDate().toString(),   // 日 "H+": date.getHours().toString(),   // 时 "M+": date.getMinutes().toString(),   // 分 "S+": date.getSeconds().toString(),   // 秒 // 有其他格式化字符需求可以继续添加,必须转化成字符串 }; for (let k in opt) { ret = new RegExp("(" + k + ")").exec(fmt); if (ret) { fmt = fmt.replace(ret[1], ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")); } } return fmt; } //获取本季度的开端月份 function getQuarterStartMonth() { let quarterStartMonth = 0 let nowMonth = new Date().getMonth() if (nowMonth < 3) { quarterStartMonth = "01" } if (nowMonth > 2 && nowMonth < 6) { quarterStartMonth = "03" } if (nowMonth > 5 && nowMonth < 9) { quarterStartMonth = "06" } if (nowMonth > 8) { quarterStartMonth = "09" } return quarterStartMonth; } module.exports = { formatTime, getQuarterStartMonth };