Javascript JS日期格式化显示


JavaScript 全选
Date.prototype.format = function (fmt) {
	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;
}
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
管理员
上一篇:化繁为简,用几个例子介绍JavaScript异步处理async awite
下一篇:Jquery请求API,AJax,Post,Get提交,失败,错误的处理
评论列表

发表评论

评论内容
昵称:
关联文章

Javascript JS日期格式化显示
ag-grid内容格式化显示 日期格式化
C# Newtonsoft日期格式化处理
CodeMirror配合js-beautify格式化代码后,光标恢复到原来位置
Razor模板编辑高亮CodeMirror和格式化JS-Beautify
javascript js 操作cookie
ag-grid内容格式化显示 金额两位小数
three.js
Devexpress gridControl SummaryItem显示格式化设置DisplayFormat
JS清除Input File 的选择文件 javascript清除Input File选择文件
CodeMirror 格式化内容和内容选择
WPF_15_格式化绑定的数据
web前端格式化缩进Razor代码,razor format
FastReport 日期格式化日期为空时报错,空日期处理
Electron edge.js配置
js Copy剪切板
DevExpress 设置DateEdit显示年月
javascript js等待几秒执行,休眠几秒中
C# 中使用JavaScript给PDF文档设置过期时间
不同状态显示不同样式 cellRendererFramework

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码