JS 2016-09-30T22:04:27.5220743+08:00 转换为日期
2024-08-20 16:16:48
1、转换代码
new Date(item.CreatedDate).Format("yyyy-MM-dd hh:mm")
2、需要拓展的方法
// 对Date的扩展,将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
// 例子:
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
Date.prototype.Format = function (fmt) { //author: zhengsh 2016-9-5
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.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;
}
最新文章
- 【blade利刃出鞘】一起进入移动端webapp开发吧
- asp.net 微信开发失效汇总
- Fragment笔记整理
- Quartz框架简介
- 基于51,人体红外感应和RC522的门禁系统
- winform无边框拖动
- ASP.NET-FineUI开发实践-16(一)
- 【回顾整理】HTML+CSS个的两个实战项目
- AngularJS如何给动态添加的DOM中绑定事件
- Python IDLE 快捷键
- SQL Server :理解BCM页
- js框架封装,模拟jQuery封装
- 我了解到的新知识之----遇到路由器DNS被篡改我该怎么办?
- python之+=与+(转载)
- Luogu P4053 [JSOI2007]建筑抢修
- Web开发相关笔记 #05# MySQL中文无法匹配
- Highlight.js语法突出显示
- linux下iostat命令详解
- MFC路径层的使用(BeginPath和EndPath函数)
- “在引用COM组件时,出现了无法嵌入互操作类型。。。”的错误
热门文章
- nodejs hello world (调用文件执行没反应)
- MySQl 存储过程+游标
- 为什么cp很多小文件非常慢——对cp和rm命令的一些思考
- django开发简易博客(三)
- Css静态进度条
- hdu 2841 Visible Trees
- A package manager for Qt
- Archive for required library: ‘WebContent/WEB-INF/lib/xxx.jar cannot&;n
- 数据结构——队列(Queues)
- 机器学习笔记(二)- from Andrew Ng的教学视频