javascript 格式化 日期

javascript 格式化 日期

<script>

Date.prototype.Format = function(formatStr)

{
var Week = ['日','一','二','三','四','五','六'];
return formatStr.replace(/yyyy|YYYY/,this.getFullYear()).replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100)).replace(/MM/,(this.getMonth()+1)>9?(this.getMonth()+1).toString():'0' + (this.getMonth()+1)).replace(/M/g,(this.getMonth()+1)).replace(/w|W/g,Week[this.getDay()]).replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate()).replace(/d|D/g,this.getDate());
};

</script>

<div class="day">
<script type="text/javascript">document.write(new Date().Format("yyyy年MM月dd日"));</script>
</div>

&nbsp;&nbsp;&nbsp;&nbsp;<script>document.write(new Date().Format("星期W"));</script>