JS 格林威治时间格式(GMT)格式化
2024-08-30 19:41:50
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
} function DateTimeFormatter(value) {
if (value == undefined) {
return "";
}
/*json格式时间转js时间格式*/
value = value.substr(1, value.length - 2);
var obj = eval('(' + "{Date: new " + value + "}" + ')');
var dateValue = obj["Date"];
if (dateValue.getFullYear() < 1900) {
return "";
}
//return dateValue
return dateValue.format("yyyy-MM-dd hh:mm:ss");
}
最新文章
- oracle基础学习
- CentOS7 监控进程网络流量工具安装
- LeetCode-Subsets
- C# 使用AutoResetEvent进行线程同步
- codeforces #305 div1 done
- (转)原子操作 Interlocked系列函数
- ZOJ 3430 Detect the Virus(AC自动机)
- JavaEE SSH集成框架(两) struts2 本地加载dtd文件,action组态
- js检测数据类型的方法你都掌握了几个?
- XML的序列化(Serializer)
- ATL编程初级教程(图文事例)(VC6)
- 运用scrollPic插件的实例
- Docker 入门到实践(三)Docker 安装
- js中使用将json数组 转换为json将一个包含对象的数组用以创建一个包含新重新格式化对象的新数组
- bugku的一道图片隐写
- 监听器&;上传下载&;I18N
- zabbix--3.0--1
- redis学习(六)redis管道
- WmS具体解释(二)之怎样理解Window和窗体的关系?基于Android7.0源代码
- python之列表【list】
热门文章
- Elasticsearch 系列1 --- Windows10安装Elasticsearch
- 用光的微粒说和广义相对论来解释衍射现象 Explanation of Diffraction Phenomenon by Particle Theory of Light and General Relativity
- 不合法的DB Index
- 一场关于 .net core 和 .net framework 编码的案情分析
- Ef-Code-First 使用实体类映射出数据库
- [学习笔记]K-D Tree
- D14——C语言基础学PYTHON
- SpringBoot配置文件application.properties详解
- Linux在终端和控制台下复制粘贴命令快捷键
- 一段奇妙的vim编辑器之旅