I’m at a loss here. I need to display a JavaScript date in my locale, but the displayed locale string is off by 1 month in the future.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var d = new Date(2018,4,3,21,0);
document.getElementById("demo").innerHTML = d.toLocaleString('de-DE');
</script>
</body>
</html>
The displayed result is 3.5.2018, 21:00:00
instead of 3.4.2018, 21:00:00
. It works correctly if I try Date.now()
instead.
Tested on both Ubuntu 14.04.5 and Linux Mint 17.3, with Firefox 59.0.2 (64-Bit) and Chromium 65.0.3325.181.
If I’m not overlooking something, I consider this a serious bug, but before filing an issue (where?) I thought I’d ask here.
Thanks for any input on this matter!
Js new Date() starts counting Month from 0 to 11.
When, you are entering new Date(2018,4,3)
It's been calculated as 3-May-2018.
And, the output is 3/5/2018.