一样的帖子??<SCRIPT LANGUAGE="JavaScript">
String.prototype.toDate = function(style){ 
var y = this.substring(style.indexOf('y'),style.lastIndexOf('y')+1);//年 
var m = this.substring(style.indexOf('M'),style.lastIndexOf('M')+1);//月 
var d = this.substring(style.indexOf('d'),style.lastIndexOf('d')+1);//日 
if(isNaN(y)) y = new Date().getFullYear(); 
if(isNaN(m)) m = new Date().getMonth(); 
if(isNaN(d)) d = new Date().getDate(); 
alert(m)
var dt ; 
eval ("dt = new Date('"+ y+"', '"+(m-1)+"','"+ d +"')"); 
return dt; 
} alert("20081009".toDate("yyyyMMdd"))
alert("200829".toDate("yyyyMd"))
</SCRIPT>String.prototype.toDate = function(style){} 
其实是类似于function toDate(style){} 
只不过这个toDate函数只能作用于string类型变量