how to put a clock

you already see my website that uses bootstrap and it does look good so now I want to add a clock into the webpage so that people can always tell time. and to do that you need to use javascript. in web development the only language you need to master is html, php, css and javascript. other than that means you’re too much of an expert.

so anyway, here is the code. you just need to put this code in any part of your index.html and it will display the time based on your computer time settings.

<!--  Clock --
var timerID = null
var timerRunning = false

function stopclock(){
    timerRunning = false

function startclock(){

function showtime(){
    var now = new Date()
    var hours = now.getHours()
    var minutes = now.getMinutes()
    var seconds = now.getSeconds()
    var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
    timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
    timeValue  += ((seconds < 10) ? ":0" : ":") + seconds
    timeValue  += (hours >= 12) ? " P.M." : " A.M."
    document.clock.face.value = timeValue 
    timerID = setTimeout("showtime()",1000)
    timerRunning = true
<BODY onLoad="startclock()">
<form name="clock" onSubmit="0">
<INPUT TYPE="text" NAME="face" SIZE=11 VALUE ="....Initializing....">



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s