Crows Free Javascript Examples

Count down to a specific date...



...and here's how it's done!

<SCRIPT LANGUAGE="Javascript"><!--

var today = new Date()
var targetdate = new Date("Jan 31, 2999")
var msPerDay = 24 * 60 * 60 * 1000 ;
var daysLeft = (targetdate.getTime() - today.getTime()) / msPerDay;
daysLeft = Math.ceil(daysLeft);

document.write("There are " + daysLeft + " days left until next Millennium!");

//--></SCRIPT>        

...here's one that will display a message when a specific date is reached!!

<SCRIPT LANGUAGE="Javascript"><!--

    var today = new Date();
    var anchor_date = new Date("Feb 01,1962");

    if (today.getMonth() == anchor_date.getMonth() 
        && today.getDate() == anchor_date.getDate())
    {
         alert("Happy Birthday, Michael!!!");
         // or other stuff on that day
    }

//--></SCRIPT>