欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

js 中国标准时间转时分秒

程序员文章站 2022-03-30 09:03:38
...
function dateFormat(date) {
        //日期格式化
        var d = new Date(date)
        let year = d.getFullYear()
        let month = d.getMonth() + 1
        month = '0' + month
        month = month.substring(month.length - 2)
        let day = '0' + d.getDate()
        day = day.substring(day.length - 2)
        let hour = '0' + d.getHours()
        hour = hour.substring(hour.length - 2)
        let m = '0' + d.getMinutes()
        m = m.substring(m.length - 2)
        let s = '0' + d.getSeconds()
        s = s.substring(s.length - 2)
        let format = year + '-' + month + '-' + day + ' ' + hour + ':' + m + ':' + s
        return format
      }
相关标签: vue.js