zoukankan      html  css  js  c++  java
  • 日期格式转换,转换格式YYYY-MM-DD HH:mm:ss

    // 获取当前时间,格式YYYY-MM-DD HH:mm:ss
    export function formatDate (timeStamp) {
      // 解决IE转换日期格式不支持-,需要替换为/或者再转为时间戳
      let isIe = ('' + timeStamp).indexOf('-')
      if (isIe > 1) {
        timeStamp = Date.parse(timeStamp.replace(/-/g, '/'))
      }
      let date = new Date(timeStamp)
      let seperator1 = '-'
      let seperator2 = ':'
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let strDate = date.getDate()
      let hour = date.getHours()
      let minute = date.getMinutes()
      let seconds = date.getSeconds()
      if (month >= 1 && month <= 9) {
        month = '0' + month
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = '0' + strDate
      }
      if (hour >= 0 && hour <= 9) {
        hour = '0' + hour
      }
      if (minute >= 0 && minute <= 9) {
        minute = '0' + minute
      }
      if (seconds >= 0 && seconds <= 9) {
        seconds = '0' + seconds
      }
      let currentdate = year + seperator1 + month + seperator1 + strDate + ' ' + hour + seperator2 + minute + seperator2 + seconds
      return currentdate
    }

    全局过滤器

    Vue.filter('FormateTimeNoSeconds', function (value) {
      return value ? formatDateNoSeconds(value) : ''
    })

    组件内使用

    <span v-else>{{ time | FormateTimeNoSeconds }}</span>
  • 相关阅读:
    cent os 6.8 php 5.6 安装ffmpeg扩展
    Linux查找目录下文件包含关键字
    python生成随机验证码
    zabbix添加任务计划和sshd文件修改key
    OS模块
    python模块
    python内建函数
    python3 爬煎蛋ooxx妹子图
    ssm整合-Sping整合Mybatis框架配置事务07
    ssm整合-Sping整合Mybatis框架06
  • 原文地址:https://www.cnblogs.com/adbg/p/13689891.html
Copyright © 2011-2022 走看看