1
<script language="JavaScript">2
Date.prototype.format = function(format) //author: meizz3


{4

var o =
{5
"M+" : this.getMonth()+1, //month6
"d+" : this.getDate(), //day7
"h+" : this.getHours(), //hour8
"m+" : this.getMinutes(), //minute9
"s+" : this.getSeconds(), //second10
"q+" : Math.floor((this.getMonth()+3)/3), //quarter11
"S" : this.getMilliseconds() //millisecond12
}13
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,14
(this.getFullYear()+"").substr(4 - RegExp.$1.length));15
for(var k in o)if(new RegExp("("+ k +")").test(format))16
format = format.replace(RegExp.$1,17
RegExp.$1.length==1 ? o[k] :18
("00"+ o[k]).substr((""+ o[k]).length));19
return format;20
}21
alert(new Date().format("yyyy-MM-dd hh:mm:ss"));22
</script>