/** * 时间戳格式化 * 时间戳为10位需*1000,时间戳为13位的话不需乘1000 * @param {*} time:时间戳 * @returns '1970-01-01 08:00:00' */ export function timestampToTime(time) { var date = new Date(time * 1000); let y = date.getFullYear(); let MM = date.getMonth() + 1; MM = MM < 10 ? "0" + MM : MM; let d = date.getDate(); d = d < 10 ? "0" + d : d; let h = date.getHours(); h = h < 10 ? "0" + h : h; let m = date.getMinutes(); m = m < 10 ? "0" + m : m; let s = date.getSeconds(); s = s < 10 ? "0" + s : s; return h + ":" + m + ":" + s; // return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s } /** * 月份名称转为英文简写 * @param {*} month :月份 * @returns Jan */ export function monthChangeEnglish(month) { if (month == "1" || month == "01") { return "Jan"; } else if (month == "2" || month == "02") { return "Feb"; } else if (month == "3" || month == "03") { return "Mar"; } else if (month == "4" || month == "04") { return "Apr"; } else if (month == "5" || month == "05") { return "May"; } else if (month == "6" || month == "06") { return "Jun"; } else if (month == "7" || month == "07") { return "Jul"; } else if (month == "8" || month == "08") { return "Aug"; } else if (month == "9" || month == "09") { return "Sept"; } else if (month == "10" || month == "10") { return "Oct"; } else if (month == "11") { return "Nov"; } else if (month == "12") { return "Dec"; } }