<meta name="viewport" content="width=device-width">
<script id="jsbin-javascript">
// every second, log time
setInterval(logClockTime, 1000);
function logClockTime() {
var time = getClockTime();
function getClockTime() {
minutes: date.getMinutes(),
seconds: date.getSeconds(),
// convert to civillian time
} else if (time.hours > 12) {
// prepend a 0 on the hours for double digits
time.minutes = '0' + time.minutes;
// prepend a 0 on the minutes for double digits
time.hours = '0' + time.hours;
// prepend a 0 on the seconds for double digits
time.seconds = '0' + time.seconds;
// format the clock time as a string 'hh:mm:ss tt'
return time.hours + ':' + time.minutes + ':' + time.seconds + ' ' + time.ampm;
<script id="jsbin-source-javascript" type="text/javascript">// every second, log time
setInterval(logClockTime, 1000);
function logClockTime() {
var time = getClockTime();
function getClockTime() {
minutes: date.getMinutes(),
seconds: date.getSeconds(),
// convert to civillian time
} else if (time.hours > 12) {
// prepend a 0 on the hours for double digits
time.minutes = '0' + time.minutes;
// prepend a 0 on the minutes for double digits
time.hours = '0' + time.hours;
// prepend a 0 on the seconds for double digits
time.seconds = '0' + time.seconds;
// format the clock time as a string 'hh:mm:ss tt'