刚入行不久,算是个实习生吧。
Date.prototype.showTime=function(isTewl){
//isTwel 选择时间制
if(!isTewl){
return this.getFullYear()+'年'+this.getMonth()+'月'+this.getDate()+'日'+this.getHours()+'时'+this.getMinutes()+'分'+this.getSeconds()+'秒';
}
else{
return this.getFullYear()+'年'+this.getMonth()+'月'+this.getDate()+'日'+(this.getHours()/12==0?this.getHours():'下午'+this.getHours()%12+'时')+this.getMinutes()+'分'+this.getSeconds()+'秒';
}
}
在Date.prototype中增加一个showTime方法,通过new Date()构造函数的方式来继承这一方法。
其实要先判断原型中是否已经存在这一方法在来增加,本人比较懒,就没写
这是我的第一条博客,有什么需要修改的地方请多多指教