0

I have a simple issue that I don't know how to fix. If I run this code in Chrome:

var event = new Date(Date.UTC(2012, 11, 5, 3, 0, 0));
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
console.log(event.toLocaleDateString('en-US', options));

The result is Tuesday, December 4, 2012 but if I run it in IE11 I get ‎Tuesday‎, ‎December‎ ‎04‎, ‎2012.

It seems that IE11 is not conforming to the format argument of day: 'numeric' and instead acts as if I specified day: '2-digit'.

So is this just IE11's fault? I couldn't find any discussion of this specific issue online. If it is, how can I work around this to get the formatting I want without the leading 0 on single-digit day numbers?

Kyle V.
  • 4,752
  • 9
  • 47
  • 81
  • I checked your code in IE11 console. It is giving out date without appending 0. Here is the output: ‎Wednesday‎, ‎December‎ ‎5‎, ‎2012 – Vikas Arora Sep 27 '18 at 16:27
  • @VikasArora That's interesting! What version are you using? I am on Version 11.0.9600.18665 with "Update Versions" at 11.0.42. I noticed your output was December 5 instead of 4... maybe you have a different system language or locale than me? – Kyle V. Sep 28 '18 at 13:32

0 Answers0