Readable date value : Date Get « Date Time « JavaScript DHTML






Readable date value

  

<HTML>
<HEAD>
<SCRIPT language="JavaScript">
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);
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

   
    
  








Related examples in the same category

1.Get Day
2.Get Seconds
3.Get Month
4.Get Milliseconds
5.Get Full Year
6.Get Year
7.Get Time
8.To Date Source
9.Convert Date to Locale String()
10.Value Of a Date
11.Output date and time in a human readble form
12.Make the time readable
13.Local time and local date
14.Use toPrecision to set the date precision