代码如下:

changeDate1(e) {
    console.log(e);
    var date =  new Date(e.detail.value); 
    console.log(date);
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
    const formatNumber = n => {
      n = n.toString()
      return n[1] ? n : '0' + n
    }
    var dateString = [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
    console.log(dateString);
    this.QueryParams.pestDate = dateString
        this.setData({
            'material.pestDate': e.detail.value
        });
  },

 

posted on 2020-12-31 09:40  周文豪  阅读(1398)  评论(0编辑  收藏  举报