javascript常用方法记录
2014-04-07 11:34
309 查看
JS下将格林威治标准时间转化为标准的北京时间
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; }
使用方法:
new Date(dt.Rows[i]['LogTime']).format("yyyy-MM-dd hh:mm:ss")
相关文章推荐
- JavaScript常用全局属性与方法记录积累
- JavaScript常用全局属性与方法记录积累
- JavaScript常用方法记录
- 『Glob』常用方法记录
- JavaScript对象创建的常用方法及各自的局限性
- JavaScript中发出HTTP请求最常用的方法
- JavaScript学习之JSON常用方法
- jquery和javascript常用方法比较
- Javascript字符串对象的常用方法简明版
- jquery和javascript的区别(常用方法比较)
- JavaScript常用数组方法
- JavaScript常用的弹出广告及背投广告实现方法
- JavaScript中日期各种问题处理,包括常用方法和转换方法
- JavaScript常用方法函数汇集
- JavaScript高级程序设计学习笔记3: Math对象比较常用的几个方法
- 19 个常用的 JavaScript 简写方法
- 题目:C++中两种常用的记录程序运行时间的方法的总结
- 记录一下自己常用的方法
- JavaScript笔记-数组常用方法