<SCRIPT language=javascript>
function String.prototype.ToStringByZero(count) //取自lostinet的函数库
{
var str=this;
while(str.length<count)str="0"+str;
return str;
}
function DateDemo(){
var d, s = "Today's date is: "; // 声明变量。
d = new Date(); // 创建 Date 对象。
s += d.getYear(); // 获取年份。
s += ((d.getMonth() + 1)+"").ToStringByZero(2); // 获取月份。
s += (d.getDate()+"").ToStringByZero(2); // 获取日。
s += (d.getHours()+"").ToStringByZero(2); // 获取时。
s += (d.getMinutes()+"").ToStringByZero(2); // 获取分。
s += (d.getSeconds()+"").ToStringByZero(2); // 获取秒。 return(s); // 返回日期。
}
alert(DateDemo())
</script>
function String.prototype.ToStringByZero(count) //取自lostinet的函数库
{
var str=this;
while(str.length<count)str="0"+str;
return str;
}
function DateDemo(){
var d, s = "Today's date is: "; // 声明变量。
d = new Date(); // 创建 Date 对象。
s += d.getYear(); // 获取年份。
s += ((d.getMonth() + 1)+"").ToStringByZero(2); // 获取月份。
s += (d.getDate()+"").ToStringByZero(2); // 获取日。
s += (d.getHours()+"").ToStringByZero(2); // 获取时。
s += (d.getMinutes()+"").ToStringByZero(2); // 获取分。
s += (d.getSeconds()+"").ToStringByZero(2); // 获取秒。 return(s); // 返回日期。
}
alert(DateDemo())
</script>
<!--
function Date.prototype.toString(){
return this.getFullYear()+"年"+(this.getMonth()+1)+"月"+this.getDate()+"日"+" "+this.getHours()+"小时"+this.getMinutes()+"分"+this.getSeconds()+"秒";
}
var d = new Date();
alert(d);
//-->
</SCRIPT>
这么写是什么意思?
直接d.getMonth()不行吗?
这种写法,需要IE6.0以后吗?