亿网中国提供全程无忧网站建设服务!
Individuals网站建设
      The website design
Individuals经典案例
      Classic case example
Individuals酷站欣赏
      The cool website enjoy

网站建设-价格体系

网站建设-建站流程

本站动态
javascript 时间对象的格式化
 
时间:2009-10-29 19:23:27

<script language="JavaScript">
Date.prototype.format = function(format) //author: meizz
{
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 hh:mm:ss"));
</script>
 
 
双击自动滚屏   打印本页 | 关闭窗口

 
 
 
QQ:
19986151
点击这里给我发消息
95616308
点击这里给我发消息
MSN: Usweb@sina.com 
 
咨询电话:021-61344944  13651600772    传真:021-61344944转18 分机
E-mail : Kind@YiwebChina.com    Info@YiwebChina.com  Usweb@sina.com    
Copyright 2002-2005 © YiwebChian.com   All Rights Reserved