How to calculate
the days remaining until Christmas:
<script>
//Set the two dates
today=new Date()
var christmas=new Date(today.getFullYear(), 11, 25)
//Month is 0-11 in Javascript
//Set 1 day in milliseconds
var one_day=1000*60*60*2
//Calculate difference between the
two dates, and convert to days
document.write(Math.ceil((christmas.getTime()-today.getTime(/(one_day))+
" days left until Christmas!"))
</script>
Example: 112 days left until Christmas!
Notice how the year for "Christmas" is
dynamically set to the current year, so the script is reusable without
the need to modify the date.
How
to calculate the time expired since the Millennium (Jan 1st, 2000):
<script>
//Set the two dates
var millennium =new Date(2000, 0, 1)//Month is 0-11 in Javascript
today=new Date()
//Get 1 day in milliseconds
var one_day=1000*60*60*2
//Calculate difference between the
two dates, and convert to days
document.write(Math.ceil((today.getTime()-millennium.getTime(/(one_day))+
" days has gone by since the Millennium!"))
</script>
Example: 978 days has gone by since the Millennium!