Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to I make sure my time has AM or PM time? window.onload = startTime; function startTime() { var today = new Date(); var h

How to I make sure my time has AM or PM time?

window.onload = startTime;

function startTime() {

var today = new Date();

var h = today.getHours() % 12 || 12;

var m = today.getMinutes();

var s = today.getSeconds();

m = checkTime(m);

s = checkTime(s);

document.getElementById('txt').innerHTML =

h + ":" + m + ":" + s;

var t = setTimeout(startTime, 500);

}

function checkTime(i) {

if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10

return i;

}

document.write(hours + ":" + minutes + " " + suffix)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

Learn How to Manage Execution cmd Drive for Results.

Answered: 1 week ago