0

This one is completely bizarre:: entering dt = Date(1680907460.) return April 17th, but dt = new Date(1680907460.) returns the null epoch. Screen snapshot shown below (Chrome).

Am I missing something in the syntax for "new Date" ??

enter image description here

Tunneller
  • 381
  • 2
  • 13
  • 1
    Keep in mind that `new Date()` needs the timestamp in **milliseconds**. Any date on 20 Jan 1970 is not "the null epoch" – Nico Haase Apr 17 '23 at 15:14
  • ```dt = Date(1680907460000)``` returns Mon Apr 17 2023, whereas ```dt = new Date(1680907460000)``` returns Fri April 7th. 2023.... Getting closer. – Tunneller Apr 17 '23 at 15:17
  • Oh!!! Which is **now**.. That only just sunk in ! :-) – Tunneller Apr 17 '23 at 15:21
  • 1
    From [MDN:](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#return_value) _Any arguments given in a Date() function call (without the new keyword) are ignored_ – 001 Apr 17 '23 at 15:22
  • Thanks, yes, I see it now. The first command `Date()` just completely ignored the value and the second command to `new Date()` was expecting milliseconds whereas I was passing seconds. Dumb of me! – Tunneller Apr 17 '23 at 15:24

0 Answers0