求日期格式的转换:读取的日期格式默认为 "2008-10-12 下午 03:00:00",我该如何设置为"2008-10-12 15:00:00"格式? 手写 js 的Date里没这些函数. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/meizz/archive/2005/06/28/405708.aspx 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; }; alert(new Date().format("yyyy-MM-dd")); javascript中如何理解闭包 如何输出到Ctrl+V的效果 这个论坛里发帖的时候那个选择论坛-子论坛的三个级联的框框是怎么实现的? webgame 世界地图 问题很菜,见笑了,谢谢啊. IE8打印问题!!!! 想了好久地问题谁可以解答? 如何改变鼠标的样式 请教高手:如何实现在论坛里点“展开显示”就可以把图片完全显示出来 求推荐靠谱的jquery ui前端框架 谁能告诉我这个tab和左边的树形菜单是怎样做的? 如何指定iframe內容重新整理?
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;
};
alert(new Date().format("yyyy-MM-dd"));