javascript - This is showing 1-24 hours i need to 1-12 hours show how i can do this? -
this showing 1-24 hours need 1-12 hours show how can ?
function onbodyload (){ var = new date(); var hr = now.gethours(); var min = now.getminutes(); var sec = now.getseconds(); document.getelementbyid('clockdisplay').innerhtml = "time " + hr + ":" + min + ":" + sec; settimeout('onbodyload()', 500); }
gethours()
returns 0-23…here how convert 1-12:
var hr = time.gethours(); if (hr > 12) { hr -= 12; } else if (hr=== 0) { hr = 12; }
Comments
Post a Comment