1. 程式人生 > 其它 >時間戳轉換

時間戳轉換

技術標籤:JS

    // //時間戳為10位需*1000,時間戳為13位的話不需乘1000
    formatDate(now) {
      now = new Date(now);
      var year = now.getFullYear();
      var month = now.getMonth() + 1;
      var date = now.getDate();
      //  var hour=now.getHours();
      //  var minute=now.getMinutes();
      //  var second=now.getSeconds();
      return year + "-" + month + "-" + date;
    },