Date Time JavaScript DHTML




function theclock(){
    var rightnow= new Date();
    
    var month= rightnow.getMonth();
    var today= rightnow.getDate();
    var year= rightnow.getYear();
    var hour= rightnow.getHours();
    var min= rightnow.getMinutes();
    var second= rightnow.getSeconds();
    
    month+=1;
    
    if (year<2000)
      year+=1900;
    
    if (hour<10)
     hour="0"+hour;
    
    if (min<10)
     min="0"+min;
    
    if (second<10)
     second="0"+second;
    
    if (hour<12)
     var ampm="AM";
    else
     var ampm="PM";
    
    if (hour==0)
      hour=12; 
    if (hour>=13) 
     hour-=12;
    
    document.write( month+"/"+today+"/"+year+" "+hour+":"+min+":"+second+" "+ampm);
}
setInterval("theclock()",1000);