字符串转日期
/*字符转日期*/StringToDate=function(DateStr){if(typeof DateStr=="undefined")return new Date();if(typeof DateStr=="date")return DateStr;var converted = Date.parse(DateStr);var myDate = new Date(converted);if(isNaN(myDate)){DateStr=DateStr.replace(/:/g,"-");DateStr=DateStr.replace(" ","-");DateStr=DateStr.replace(".","-");var arys= DateStr.split('-');switch(arys.length){case 7 : myDate = new Date(arys[0],--arys[1],arys[2],arys[3],arys[4],arys[5],arys[6]);break;case 6 : myDate = new Date(arys[0],--arys[1],arys[2],arys[3],arys[4],arys[5]);break;default: myDate = new Date(arys[0],--arys[1],arys[2]);break;};};return myDate;}
posted on 2013-04-04 16:44 YEKEYISHUO 阅读(253) 评论(0) 编辑 收藏 举报