+ 1

How to make my code to 12 hr format

Please help me https://code.sololearn.com/Wp74kQP4W5vt/?ref=app

17th May 2022, 6:41 AM
Jishnu Satheesh Pulickal
4 Réponses
+ 1
Jishnu Satheesh Pulickal (Challenger) Changes made to line 3 & line 6 function start() { var today = new Date(); var h = today.getHours() %12; var m = today.getMinutes(); var s = today.getSeconds(); h = correctTime(h) m = correctTime(m); s = correctTime(s); document.getElementById('clock').innerHTML = h + ":" + m + ":" + s; var t = setTimeout(start, 1000); } function correctTime(i) { if (i < 10) { i = "0" + i; } return i; }
17th May 2022, 9:39 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Rik Wittkopp Thank you
17th May 2022, 11:03 AM
Jishnu Satheesh Pulickal
+ 1
Check this I think this will help you https://codepen.io/jaystephens3/pen/eYbOQx
17th May 2022, 6:47 AM
Gayatri Dunakhe
Gayatri Dunakhe - avatar
17th May 2022, 6:52 AM
Mustafa A
Mustafa A - avatar