年月日

return(
 nowTime: this.$moment(new Date()).format('HH:mm:ss'),
 nowDay: this.formatDate(),
 nowWeek: this.getWeekDate(),
)
methods:{
//  年月日
      formatDate() {
      const date = new Date()
      var year = date.getFullYear()
      var month = date.getMonth() + 1
      var weekday = date.getDate()
      if (month < 10) {
        month = '0' + month
      }
      if (weekday < 10) {
        weekday = '0' + weekday
      }
      return year + '年' + month + '月' + weekday + '日'
    },
//  星期
    getWeekDate() {
      const day = new Date().getDay()
      const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
      return weeks[day]
    }
}
 
posted @ 2022-02-07 15:19  笨笨白  阅读(85)  评论(0编辑  收藏  举报