// 参数number为毫秒时间戳,format为需要转换成的日期格式
export function formatTime (number, format) {
let time = new Date(number)
let newArr = []
let formatArr = ['Y', 'M', 'D', 'h', 'm', 's', 'i']
newArr.push(time.getFullYear())
newArr.push(formatNumber(time.getMonth() + 1))
newArr.push(formatNumber(time.getDate()))
newArr.push(formatNumber(time.getHours()))
newArr.push(formatNumber(time.getMinutes()))
newArr.push(formatNumber(time.getSeconds()))
newArr.push(formatNumber(time.getMilliseconds()))
for (let i in newArr) {
format = format.replace(formatArr[i], newArr[i])
}
return format
}
//------------------------------------
this.formatTime(new Date(), 'Y-M-D')