Javascript String to_date()
String.prototype.to_date = function(){ // don't quite understand it, but I need to convert this string to a string? // otherwise it is invalid d = new Date(this.toString()); if( d == "Invalid Date" ) { if(this.length == 8){ /* 19991231 */ d = new Date(this.substr(0,4), this.substr(4,2).to_i()-1, this.substr(6,2)); }/*from w ww .j a v a 2s . com*/ } return d; }