Date.prototype.format = 함수(형식) {
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(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));
반환 형식;
}
var TempDate = new Date();
TempDate.toLocaleDateString()//2013年9月4日
TempDate.format("yyyy-MM-dd")//2013-09-04