Date and Time

Description

Displays date/time as (Day, Month and Date, Year Hour:Minute:Second:AM/PM).

Code

Place this HTML where you want the clock to appear.

<div id="clockbox"></div>

Insert this javascript snippet at the end of the page.

<script type="text/javascript">
  var tday=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
  var tmonth=["January","February","March","April","May","June","July","August","September","October","November","December"];

  function GetClock(){
    var d=new Date();
    var nday=d.getDay(),nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getFullYear();
    var nhour=d.getHours(),nmin=d.getMinutes(),nsec=d.getSeconds(),ap;

    if(nhour==0){ap=" AM";nhour=12;}
    else if(nhour<12){ap=" AM";}
    else if(nhour==12){ap=" PM";}
    else if(nhour>12){ap=" PM";nhour-=12;}

    if(nmin<=9) nmin="0"+nmin;
    if(nsec<=9) nsec="0"+nsec;

    var clocktext=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+"";
    document.getElementById('clockbox').innerHTML=clocktext;
  }

  GetClock();
  setInterval(GetClock,1000);
</script>