0

Why were the commands designed to have different outputs? Note how Date(epoch) yields the current time instead of parsing it. I stumbled upon this by accident and think it can introduce some nasty bugs if one is not aware of this.

> Date(1596748882000)
'Tue Aug 11 2020 18:49:21 GMT+0200 (Central European Summer Time)'
> new Date(1596748882000)
2020-08-06T21:21:22.000Z
sedot
  • 577
  • 5
  • 16
  • Dupe does not explain why it reports a different date. – epascarello Aug 11 '20 at 17:07
  • "Because spec" is a reasonable answer for me, but not satisfying. I reworded the question. – sedot Aug 11 '20 at 17:11
  • 1
    @sedot the usual answer for these things in JS is backwards compatibility, there probably was once a time when the Date object didn't exist and it was just the function – Klaycon Aug 11 '20 at 17:13

0 Answers0