new Date时间戳格式-转换yyyy-MM-dd

      formatDate(date) {
        var year = date.getFullYear()
        var month = this.format(date.getMonth() + 1)
        var da = this.format(date.getDate())
        // var h = this.format(date.getHours())
        // var m = this.format(date.getMinutes())
        // var s = this.format(date.getSeconds())
        // return year + '-' + month + '-' + da + ' ' + h + ':' + m + ':' + s
        return year + '-' + month + '-' + da
      },
      format(val) {
        return Number(val) < 10 ? '0' + val : '' + val
      },

  

posted @ 2020-03-18 10:25  小白咚  阅读(6434)  评论(0编辑  收藏  举报