I have simple question about Javascript date() function. This is a snippet of code
var today = new Date(); // current date
var xmas = new Date(2011,12,25); // this xmas
alert(Math.round ( today / (1000*60*60*24) ) ); // transform into number of days
alert(Math.round ( xmas / (1000*60*60*24) ) ); // transform into number of days
The output is as the following, respectively:
15141 // today
15364 // xmas
I don’t know what does it mean by these numbers? 15141 (or 14999) days compare to what?
I also made another simple calculation to find the number of days from now to this year’s xmas, to see if the above calculation is correct:
var total_days = Math.round(xmas/(1000*60*60*24)) - Math.round(today/(1000*60*60*24));
alert( total_days );
It returns 223 (days), this is correct.
So turning back to the orignal question, what does it mean by those numbers?
Javascript time starts at 1 January 1970 00:00:00 UTC. So its 14999 days since then.