2

I have encountered a bug in Intl.DateTimeFormat MDN

Environment

Internet Explorer 11.0.6900.19080 on Windows 7

Bug

When only the "2-digit" option is used for month + day the function is not outputting any separators, be it / for en or . for de. This happens only in Internet Explorer on Windows 7. Internet Explorer 11 + Edge on Windows 10 is working. Not tested lower than 11.

Internet Explorer

Intl.DateTimeFormat('en', {month: "2-digit", day: "2-digit"}).format(new Date());
> "‎07‎ ‎25"

Intl.DateTimeFormat('en', {year: "numeric", month: "2-digit", day: "2-digit"}).format(new Date());
> "‎07‎/‎25‎/‎2018"

Chrome

Intl.DateTimeFormat('en', {month: "2-digit", day: "2-digit"}).format(new Date());
> "07/25"

Intl.DateTimeFormat('en', {year: "numeric", month: "2-digit", day: "2-digit"}).format(new Date());
> "07/25/2018"

Context

I have used react-intl when this error occurred and traced the error back to the native Intl.DateTimeFormat()

<FormattedDate
    value={new Date()}
    month="2-digit"
    day="2-digit"
/>
Hyyan Abo Fakher
  • 3,497
  • 3
  • 21
  • 35
Marvin Fischer
  • 2,552
  • 3
  • 23
  • 34

1 Answers1

3

According to caniuse.com DateTimeFormat full support was added to IE11 on released version oct 17 ,2013, so it might be that your Windows 7 has an older version, you can check this by clicking on the link beside the version number.

enter image description here

To fix your issue, you can

  • Update IE11 (I don't think it is a solution) this will work only for you
  • Add the separator manually according to your app supported languages

Intl.DateTimeFormat('en', {
    month: "2-digit",
    day: "2-digit"
  })
  .format(new Date()).split(" ").join("/");
  • Use the following polyfill to get full support
Hyyan Abo Fakher
  • 3,497
  • 3
  • 21
  • 35