对Date的扩展,将 Date 转化为指定格式的String
来源:互联网 发布:mac的ip地址是什么 编辑:程序博客网 时间:2024/05/14 06:01
// 对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) { 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;}
0 0
- 对Date的扩展,将 Date 转化为指定格式的String
- 对Date的扩展,将 Date 转化为指定格式的String
- JS 时间格式化 对Date的扩展,将 Date 转化为指定格式的String
- 对Date的扩展,将 Date 转化为指定格式的String
- 对Date的扩展,将 Date 转化为指定格式的String
- 四八、js封装格式化时间(将 Date 转化为指定格式的String)
- sprmvc将前台String转化为后台的Date类型
- java中如何将String类型的日期格式为yyyyMMdd转化为date类型的yyyy-MM-dd格式
- 页面对date的格式转化
- JS将String格式转化Date
- java Date格式的string转换为Date类型
- 将String类型转化为Date类型
- J2SE 将String转化为Date
- JS将String转化为Date
- 将未指定格式的日期字符串转化成java.util.Date类型日期对象
- 将未指定格式的日期字符串转化成java.util.Date类型日期对象
- 全局将String 转换为Date格式
- Date 和 String 的转化
- SpringMVC使用session实现简单登录
- 项目上传git仓库步骤
- CSU 1519: Sum of Integers
- Leetcode-valid-palindrome
- Android Studio 代码混淆
- 对Date的扩展,将 Date 转化为指定格式的String
- AndroidStudio继承或实现onclicklistener实现点击功能
- Ajax跨域请求COOKIE无法带上的解决办法
- poj 1383 (树的直径加上bfs)
- Sql Server 日期格式化函数 (类似Format函数),一般用于存储过程中
- Leetcode 238. Product of Array Except Self
- js面向对象 不懂为什么要init进行初始化
- Android - ListView滑动指定tiem和滑动固定距离
- VB程序学习代码记录20160802