2014年5月4日 星期日

Result of toJSON() on a date is different between IE8 and IE9+

Prior to ES5, parsing of dates was entirely implementation dependent. IE 8 (and lower) won't parse the ISO 8601 format specified in ES5, so just parse it yourself:
// parse ISO format date like 2013-05-06T22:00:00.000Z
function dateFromISO(s) {
  s = s.split(/\D/);
  return new Date(Date.UTC(s[0], --s[1]||'', s[2]||'', s[3]||'', s[4]||'', s[5]||'', s[6]||''))
}
Assumes the string is UTC.

reference : http://stackoverflow.com/questions/17592717/result-of-tojson-on-a-date-is-different-between-ie8-and-ie9

沒有留言:

wibiya widget