Time And Date

The following time and date script shows 12 hour clock (AM/PM), can i make it show 24 hours, like 13.00:05?<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><HEAD><br /><br /><script LANGUAGE="javascript"><br /><!-- Original:  Craig Lumley --><br /><!-- Web Site:  http://www.ws4all.co.uk --><br /><br /><!-- This script and many more are available free online at --><br /><!-- The javascript Source!! http://javascript.internet.com --><br /><br /><!-- Begin<br />function MakeArrayday(size) {<br />this.length = size;<br />for(var i = 1; i <= size; i++) {<br />this = "";<br />}<br />return this;<br />}<br />function MakeArraymonth(size) {<br />this.length = size;<br />for(var i = 1; i <= size; i++) {<br />this = "";<br />}<br />return this;<br />}<br />function funClock() {<br />if (!document.layers && !document.all)<br />return;<br />var runTime = new Date();<br />var hours = runTime.getHours();<br />var minutes = runTime.getMinutes();<br />var seconds = runTime.getSeconds();<br />var dn = "AM";<br />if (hours >= 12) {<br />dn = "PM";<br />hours = hours - 12;<br />}<br />if (hours == 0) {<br />hours = 12;<br />}<br />if (minutes <= 9) {<br />minutes = "0" + minutes;<br />}<br />if (seconds <= 9) {<br />seconds = "0" + seconds;<br />}<br />movingtime = ""+ hours + ":" + minutes + ":" + seconds + " " + dn + "";<br />if (document.layers) {<br />document.layers.clock.document.write(movingtime);<br />document.layers.clock.document.close();<br />}<br />else if (document.all) {<br />clock.innerHTML = movingtime;<br />}<br />setTimeout("funClock()", 1000)<br />}<br />window.onload = funClock;<br />//  End --><br /></script><br /></HEAD><br /><br />and<br /><br /><BODY><br /><span id=clock style="position:relative;"></span><!--c2--></div><!--ec2--><br /><br />-Thomas<!--content-->
Thomas, Go here to get the edited code for your 24 hour time:<br /><br /><a href="http://www.cmg02.com/test1/thomastime.htm" target="_blank">http://www.cmg02.com/test1/thomastime.htm</a><!--content-->
I've heard that javascript grabs the time from the user's computer... which has some advantages and disadvantages.<br /><br />If you wanted to do it server side and use the time on the server, you could do it like this<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php echo date("H.i:s") ?><!--c2--></div><!--ec2--><!--content-->
Thanks Jack <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> , but im not too good at php yet, so I go with Curtis thing this time.<br />Just one question... Is there a way I can get rid of the AM/PM thing. No need for it if it shows 24 hours time.<br /><br />-Thomas<!--content-->
Thomas, I removed the AM and PM. Try it again at the above url<!--content-->
Works and looks great.<br />Thank you Curtis. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <br /><br />-Thomas<!--content-->
 
Back
Top