rikkitikkitumbo rikkitikkitumbo - 2 months ago 15
Javascript Question

IE Date.toLocaleTimeString().split isn't returning an array of strings

This is straight from the console in IE (Microsoft Edge 25.10):

greg = new Date().toLocaleTimeString().split(':')[0];
greg = new Date().toLocaleTimeString().split(':')[0]=="12";



It's because there are two invisible characters in the string: U-200E (left-to-right marks) at the beginning and end:

new Date().toLocaleTimeString().split(':')[0] == "\u200e12\u200e" // true

toLocaleTimeString is defined here by ECMA-402 if the browser supports ECMA-402; otherwise, it's completely up to the implementation. IE doesn't support ECMA-402 and thus it can put anything in that string it likes. Including left-to-right marks seems a bizarre thing to do, but...