• js 时间格式化 兼容safari 苹果手机


    export function formatTime (fmt, date) {
      date = new Date(date + '+08:00') // 兼容safari
      var o = {
        'M+': date.getMonth() + 1,
        'd+': date.getDate(),
        'h+': date.getHours(),
        'm+': date.getMinutes(),
        's+': date.getSeconds(),
        'q+': Math.floor((date.getMonth() + 3) / 3),
        'S': date.getMilliseconds()
      }
      if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
      }
      for (var k in o) {
        if (new RegExp('(' + k + ')').test(fmt)) {
          fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
        }
      }
      return fmt
    }
    export default {
      formatTime
    }
    let start = formatTime('yyyy-mm-dd hh:mm', '2019-05-01T09:00:00') // 2019-05-01 09:00 兼容了safari
     
    new Date('2019-05-01T09:06:08') 改为new Date('2019-05-01T09:06:08+08:00') 就同时兼容浏览器

    https://blog.csdn.net/qq_34849240/article/details/80736624

  • 相关阅读:
    输出函数
    curl
    页眉的章名和章名不统一
    水平柱状图
    目录和正文的页码生成
    protobuf的使用
    yarn vue安装
    nvm node的安装
    win安装postman
    机器码
  • 原文地址:https://www.cnblogs.com/xiangsj/p/10746044.html
Copyright © 2020-2023  润新知