Date.prototype.Format=function(formatStr){return formatStr.replace(/yyyy|YYYY/,this.getFullYear()).replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100)).replace(/MM/,(this.getMonth()+1)>9?(this.getMonth()+1).toString():'0' + (this.getMonth()+1)).replace(/M/g,(this.getMonth()+1)).replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate()).replace(/d|D/g,this.getDate()).replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours()).replace(/h|H/g,this.getHours()).replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes()).replace(/m/g,this.getMinutes()).replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds()).replace(/s|S/g,this.getSeconds()).replace(/w|W/g,['日','一','二','三','四','五','六'][this.getDay()]);};
var timer=Date.parse("12/30/2017 12:00:00");
alert( new Date(timer).Format("YYYY年MM月DD") ) //2017年12月30
alert( new Date(timer).Format("YYYY年MM月DD日 HH时mm分SS秒 星期W") ) //2017年12月30日 12时00分00秒 星期六
var str="2017-11-17Tsdfsdfsdf";
str=str.replace(/(.*)T.*$/,"$1");