JavaScript Current Time Clock


This javascript code will display the current time from the client’s computer. This will display the format you might see on a typical digital clock -- HH:MM AM/PM (H = Hour, M = Minute).

<h4>The Current Time Is 
<script type="text/javascript">
<!--
var dateobj = new Date()
var hrs = dateobj.getHours()
var min = dateobj.getMinutes()
if (min < 10){
min = "0" + min
}
document.write(hrs + ":" + min + " ")
if(hrs > 11){
document.write("PM")
} else {
document.write("AM")
}
//-->
</script>
</h4>

Display:

The Current Time Is

Tags: , , ,

Join Us!