javascript自定义日期格式化

 1 <script>
 2     Date.prototype.formateDate=function(){
 3         var str="";
 4         str+=this.getFullYear()+"年";
 5         str+=(this.getMonth()+1)+"月";
 6         str+=this.getDate()+"日";
 7         return str;
 8     }
 9     var date=new Date();
10     alert(date.formateDate());
11 </script>

 

posted @ 2017-02-09 10:56  疯子~  阅读(313)  评论(0编辑  收藏  举报