网络上找的JS日期格式化简洁版
来源:互联网 发布:c语言图形程序设计 编辑:程序博客网 时间:2024/06/16 20:28
日期格式化
代码
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; };
使用
alert((new Date()).format("yyyy-MM-dd hh:mm:ss"))
其他选择 http://momentjs.cn
阅读全文
0 0
- 网络上找的JS日期格式化简洁版
- js日期的格式化
- 超简洁的js 日期选择控件
- js 格式化显示日期 -- 搜索自网络
- js的日期格式化函数
- js的日期格式化函数
- 一个JS的 日期格式化算法
- js格式化日期时间的工具方法
- js日期转换--日期格式化
- JS解析,格式化日期
- js日期格式化
- js日期格式化
- js时间日期格式化
- js日期格式化
- js格式化日期
- js日期格式化函数
- js日期格式化
- js 格式化日期
- css3 选择器
- CDH5实践(补充)一些问题的处理
- Linux 进程状态转换
- JS常用正则表达式验证总结。
- python学习之运维应用
- 网络上找的JS日期格式化简洁版
- STL学习笔记10— —容器的选用
- [RK3288][Android6.0] 开发者选项中的Strict mode功能
- 使用最大公约数求线段上格点的个数
- UVA 11827 Maximum GCD
- FreeBSD代码目录说明
- SpringMVC中MessageSource的获取方法
- oracle的sql语句的练习题及答案(员工表+部门表)
- webpack编译多页面vue项目的配置问题