日期:2014-05-16  浏览次数:20336 次

js 格式化时间日期函数

[代码] [JavaScript]代码

01 /**
02 ?* 时间对象的格式化;
03 ?*/
04 Date.prototype.format = function(format) {
05 ????/*
06 ?????* eg:format="YYYY-MM-dd hh:mm:ss";
07 ?????*/
08 ????var o = {
09 ????????"M+" :this.getMonth() + 1, // month
10 ????????"d+" :this.getDate(), // day
11 ????????"h+" :this.getHours(), // hour
12 ????????"m+" :this.getMinutes(), // minute
13 ????????"s+" :this.getSeconds(), // second
14 ????????"q+" :Math.floor((this