im using jquery for this matter easy in/out
i made a simple program just now, to make it simple all the variables i save is from this simple code
function getClock(){
var d = new Date();
var nhour = d.getHours(),nmin=d.getMinutes(),nsec=d.getSeconds(),ap;
if (nhour == 0) {
ap = " AM";
nhour = 12;
} else if (nhour < 12) {
ap = " AM";
} else if (nhour == 12) {
ap = " PM";
} else if (nhour > 12) {
ap = " PM";
nhour -= 12;
}
var nminTot = nmin <= 9 ? nmin = "0" + nmin : nmin;
var nsecTot = nsec <= 9 ? nsec = "0" + nsec : nsec;
$("#clockbox").html(nhour + ":" + nminTot + ":" + nsecTot + ap);
}
setInterval(getClock, 1000)
very short time clock design easy to get variables.
http://jsfiddle.net/2pqn6a1z/6/