Status Time using JavaScript


This script displays the time, day, date and month in the status bar.

<script>

var all;
var month;
var period;
var day;

function time(){
var currentDate=new Date()
hour=currentDate.getHours()
min=currentDate.getMinutes()
sec=currentDate.getSeconds()
date=currentDate.getDate()

switch(currentDate.getMonth()){

case 0:month="January";break;
case 1:month="Febuary";break;
case 2:month="March";break;
case 3:month="April";break;
case 4:month="May";break;
case 5:month="June";break;
case 6:month="July";break;
case 7:month="August";break;
case 8:month="September";break;
case 9:month="October";break;
case 10:month="November";break;
case 11:month="December";break;


switch(currentDate.getDay()){

case 0:day="Sunday";break;
case 1:day="Monday";break;
case 2:day="Tuesday";break;
case 3:day="Wednesday";break;
case 4:day="Thursday";break;
case 5:day="Friday";break;
case 6:day="Saturday";break;
}

if(sec<10){sec="0"+sec}
if(min<10){min="0"+min}
if(hour>12){hour-=12;period="pm"} else {period="am"}
if(currentDate.getHours()==12){period="pm"}
if(currentDate.getHours()==24){period="am"}
var all= "Today is " + day + "," + month + " " + date + ".The time is "+hour+":"+min+":"+ sec + period ;
window.status=all
window.setTimeout("time()",300)
}

time()

</script>




Added on July 3, 2007 Comment
}