对Date的扩展,将 Date 转化为指定格式的String
来源:互联网 发布:java调用ssh协议 编辑:程序博客网 时间:2024/05/16 19:24
<script type="text/javascript">//对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: meizz 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;}</script>
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 的转化
- 做网站可以用百度文库
- 香港教育(7)——高中课程旧制
- c++ Lambda表达式
- 也就是说在有异步回调函数的情况下,方法的返回值基本都是不能使用的。【也有特殊情况】
- 位置信息引用百度地图
- 对Date的扩展,将 Date 转化为指定格式的String
- Android软键盘的隐藏显示
- EXCEL表从两张表中比对相同的数据后追加公式
- tslib1.4 移植全过程
- C语言中处理密码
- VMware网络模式介绍(下篇)
- 通过序列化实现深拷贝
- 20140401笔记
- Asp.net MVC文章搜集索引