javascript下ie7,ie8的Date Bug的解决
[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4994200.html]
1 function parseISO8601(dateStringInRange) { 2 var isoExp = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/, 3 date = new Date(NaN), month, 4 parts = isoExp.exec(dateStringInRange); 5 6 if(parts) { 7 month = +parts[2]; 8 date.setFullYear(parts[1], month - 1, parts[3]); 9 if(month != date.getMonth() + 1) { 10 date.setTime(NaN); 11 } 12 } 13 return date; 14 }
ajax后台返回格式为"XXXX-XX-XXTXX:XX:XX"
调用方式:var BeginTime = new Date(parseISO8601(m_ProjectTEN.BeginTime.split('T')[0]));