const prefixZero = (num) => {
    return (Array(2).join(0) + num).slice(-2);
}

const dealTime = (fromtime) => {
    const myDate = new Date(fromtime)
    let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)  
    let month = myDate.getMonth(); //获取当前月份(0-11,0代表1月)         // 所以获取当前月份是myDate.getMonth()+1;   
    let date = myDate.getDate(); //获取当前日(1-31)  
    let hour = myDate.getHours(); //获取当前小时数(0-23)  
    let minutes = myDate.getMinutes(); //获取当前分钟数(0-59)  
    let seconds = myDate.getSeconds(); //获取当前秒数(0-59)  
    month = prefixZero(month + 1)
    date = prefixZero(date)
    hour = prefixZero(hour)
    minutes = prefixZero(minutes)
    seconds = prefixZero(seconds)
    return `${year}-${month}-${(date)} ${hour}:${minutes}:${seconds}`
}

export default {
    dealTime,
    prefixZero
}