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
}
new Date('2019-05-01T09:06:08+08:00') 就同时兼容浏览器https://blog.csdn.net/qq_34849240/article/details/80736624
js 时间格式化 兼容safari 苹果手机的更多相关文章
- js 时间格式化 (兼容safari)
js 时间格式化,兼容IE8和safari浏览器. function formatDate(date, fmt, near, type) { var dateStr = date; if (!date ...
- js时间格式化函数,支持Unix时间戳
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 时间戳显示为多少分钟前,多少天前的JS处理,JS时间格式化,时间戳的转换
var dateDiff = function (timestamp) { // 补全为13位 var arrTimestamp = (timestamp + '').split(''); for ( ...
- 表单序列化json字符串和js时间格式化
js时间格式化 new Date().format("时间格式") Date.prototype.format = function(fmt) { var o = { ...
- js时间格式化函数(兼容IOS)
* 时间格式化 * @param {Object} dateObj 时间对象 * @param {String} fmt 格式化字符串 */ dateFormat(dateObj, fmt) { le ...
- js时间格式化
const formatDate = timestamp => { const date = new Date(timestamp); const m = date.getMonth() + 1 ...
- js时间格式化(yy年MM月dd日 hh:mm)
//时间格式化 Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, / ...
- js 时间格式化 -- 时间加减实现
时间格式化的方法: Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.ge ...
- JS 时间格式化函数
//时间格式化函数 Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, ...
随机推荐
- DataPipeline CTO陈肃:从ETL到ELT,AI时代数据集成的问题与解决方案
引言:2018年7月25日,DataPipeline CTO陈肃在第一期公开课上作了题为<从ETL到ELT,AI时代数据集成的问题与解决方案>的分享,本文根据陈肃分享内容整理而成. 大家好 ...
- C# 获取当前服务器运行程序的根目录,获取当前运行程序物理路径
C# 获取当前服务器运行程序的根目录,获取当前运行程序物理路径 string tmpRootDir = AppDomain.CurrentDomain.BaseDirectory;//获得当前服务器程 ...
- thinkPHP HTML输出多条查询结果
控制端 $select=M('Baojiao')->query("select * from think_Baojiao where COMPANY='$comname'") ...
- C# -- 使用Ping检查网络是否正常
C# -- 使用Ping检查网络是否正常 需引用命名空间: using System.Net.NetworkInformation; 1. 代码实现 try { List<string> ...
- 关于Http
摘自:菜鸟教程 HTTP简介 HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(www)服务器传输超文本到本地浏览器的传送协议. HTTP ...
- 03 前端篇(JS)
参考博客:http://www.cnblogs.com/yuanchenqi/articles/5980312.html JavaScript包括三部分: ECMAScript.DOM.BOM Jav ...
- python标准日志模块logging及日志系统设计
最近写一个爬虫系统,需要用到python的日志记录模块,于是便学习了一下. python的标准库里的日志系统从Python2.3开始支持.只要import logging这个模块即可使用.如果你想开发 ...
- redis 的过期策略都有哪些?内存淘汰机制都有哪些?
面试题 redis 的过期策略都有哪些?内存淘汰机制都有哪些?手写一下 LRU 代码实现? 面试官心理分析 如果你连这个问题都不知道,上来就懵了,回答不出来,那线上你写代码的时候,想当然的认为写进 r ...
- tsc.exe 已退出 代码为 1
从微软官网下载TypeScript_Dev14Full,解决问题,下载地址https://www.microsoft.com/zh-CN/download/confirmation.aspx?id=4 ...
- springdata 动态查询之分页