export function timestampToTime(timestamp) {
        let date = new Date(timestamp);
        let year = date.getFullYear();
        let month = ("0" + (date.getMonth() + 1)).slice(-2);
        let day = ("0" + date.getDate()).slice(-2);
        let hour = ("0" + date.getHours()).slice(-2);
        let minute = ("0" + date.getMinutes()).slice(-2);
        let second = ("0" + date.getSeconds()).slice(-2);
        let formattedTime = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
        return formattedTime;
     }
     export function timescount(timestamp) {
      var date = new Date(timestamp*1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
      console.log(date);
       let year = date.getFullYear();
       let month = ("0" + (date.getMonth() + 1)).slice(-2);
       let day = ("0" + date.getDate()).slice(-2);
       let hour = ("0" + date.getHours()).slice(-2);
       let minute = ("0" + date.getMinutes()).slice(-2);
       let second = ("0" + date.getSeconds()).slice(-2);
       let dTime = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
        return dTime;
    }
    export function formatTime(time, fmt) {
        if (!time) return '';
        else {
          const date = new Date(time);
          const o = {
            'M+': date.getMonth() + 1,
            'd+': date.getDate(),
            'H+': date.getHours(),
            'm+': date.getMinutes(),
            's+': date.getSeconds(),
            'q+': Math.floor((date.getMonth() + 3) / 3),
            S: date.getMilliseconds(),
          };
          if (/(y+)/.test(fmt))
            fmt = fmt.replace(
              RegExp.$1,
              (date.getFullYear() + '').substr(4 - RegExp.$1.length)
            );
          for (const k in o) {
            if (new RegExp('(' + k + ')').test(fmt)) {
              fmt = fmt.replace(
                RegExp.$1,
                RegExp.$1.length === 1
                  ? o[k]
                  : ('00' + o[k]).substr(('' + o[k]).length)
              );
            }
          }
          return fmt;
        }
      }
      
