DEV Community

Discussion on: Countdown Timer using HTML, CSS, and Javascript

supportic profile image
Supportic • Edited on

No worries new Date(undefined) always throws 'Invalid Date' in the console and new Date(null) returns the starting point.
Thanks for the neat snippet though.
Could you also explain why we subtract 621672192e5 ?

Thread Thread
lukeshiru profile image
LUKESHIRU

Sure, that 621672192e5 value is 0000-01-01T00:00:00.000Z, so the "first day" of the Gregorian calendar, if we have two dates and we subtract that, we get the "difference" between those two dates ... this is still the "cheap/non-exact" version, if you want something more useful, you might have to update it so it does the actual values for each property. I might do that later so the example is more useful for other folks.