js实现类似C# 时间格式化、时间运算
来源:互联网 发布:淘宝热点乱接错位 编辑:程序博客网 时间:2024/06/05 12:01
/** * js时间对象的格式化;* eg:format="yyyy-MM-dd hh:mm:ss"; */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;}/***js中更改日期 * y年, m月, d日, h小时, n分钟,s秒 */Date.prototype.add = function (part, value) { value *= 1; if (isNaN(value)) { value = 0; } switch (part) { case "y": this.setFullYear(this.getFullYear() + value); break; case "m": this.setMonth(this.getMonth() + value); break; case "d": this.setDate(this.getDate() + value); break; case "h": this.setHours(this.getHours() + value); break; case "n": this.setMinutes(this.getMinutes() + value); break; case "s": this.setSeconds(this.getSeconds() + value); break; default: }}
0 0
- js实现类似C# 时间格式化、时间运算
- 类似这种时间的格式化
- 【js】js时间格式化
- C#实现毫秒到格式化时间串
- js实现格式化时间转换为时间戳
- C#格式化日期时间
- C#日期格式化,时间
- C#时间转换格式化
- C#日期时间格式化
- C#日期时间格式化
- C#日期时间格式化
- C#格式化时间
- C#格式化时间
- C#日期时间格式化
- c# 格式化时间字符串
- c# 时间格式化
- C#时间格式化
- C# 时间格式化
- PHP实现斐波那契序列
- poj Countries in War(强连通+最短路)
- 《大话设计模式》- 策略模式 - C++实现
- cmake入门教程
- 快速排序—java实现
- js实现类似C# 时间格式化、时间运算
- 防止重复提交的解决方法
- 详细说明phpmyadmin连接,管理多个mysql服务器
- 将一句话中的单词进行倒换,标点符号不倒换,要求不使用辅助空间
- 如何访问web-inf 下的页面
- 使用vi编辑器删除文本中所有空行
- Oracle GoldenGate下载地址
- MFC中,什么是CALLBACK函数,什么是WINAPI函数,二者有什么区别和联系?
- 【struts2】五大核心jar包 和 作用