

//时间戳转化 转换时间为yyyy-mm-dd hh:mm:ss的格式
// type 1:yyyy-mm-dd hh:mm:ss 2 yyyy-mm-dd
export const dateChangeYYYY = (str, type) => {
    var date = '';
    var sTime1 = new Date(str)
    if (type == 1) {
        date = sTime1.getFullYear() + '-' + double(sTime1.getMonth() + 1) + '-' + double(sTime1.getDate()) +
            " " + double(sTime1.getHours()) + ':' + double(sTime1.getMinutes()) + ':' + double(sTime1.getSeconds());
    } else if (type == 2) {
        date = sTime1.getFullYear() + '-' + double(sTime1.getMonth() + 1) + '-' + double(sTime1.getDate())
    } else if (type == 3) {
        // date = sTime1.getFullYear() + '-' + double(sTime1.getMonth() + 1) + '-' + double(sTime1.getDate())
        date = {
            year: sTime1.getFullYear(),
            month: sTime1.getMonth() + 1,
            day: sTime1.getDate()
        }
    }
    return date;
}
const double = (t) => {
    return t < 10 ? '0' + t : t;
}

export const doubleStr = (s) => {
    const a = s.toString()
    return a[1] ? a : `0${a}`
  }
  