zoukankan      html  css  js  c++  java
  • 在js中如何将字符串类型的日期("2020-11-30T02:21:42.000+0000")进行格式化

    1、引入方法

    import { formatDateNew } from '@/utils'

    2、在方法中使用,注意要先将字符串进行new Date(),否则报错date.getFullYear is not a function

    methods: {
        openDialog(data) {
          console.log(data)
          this.dialogFormVisible = true
          this.edit = Object.assign({}, data)
          this.edit.productionDate = formatDateNew(new Date(this.edit.productionDate), 'yyyy-MM-dd')
          this.edit.expireDate = formatDateNew(new Date(this.edit.expireDate), 'yyyy-MM-dd')
          console.log(this.edit)
        },
    }

    微信小程序中如何对日期进行格式化?

    
    
    //发货日期
                const sendDate = result.data.sendDate
                if (sendDate == null || sendDate == '') {
                  result.sendDate = ''
                } else {
                  result.data.sendDate = util.formatDate(new Date(sendDate))
                }
  • 相关阅读:
    50
    49
    Windows编程之connect函数研究
    48
    C++创建窗口程序初步
    47
    46
    45
    计算机组成原理实验思路
    44(function pointer 2)
  • 原文地址:https://www.cnblogs.com/zwh0910/p/14060115.html
Copyright © 2011-2022 走看看