Strygun Posted August 21, 2007 Share Posted August 21, 2007 Hey folks, I've found some code on the internet that will create a very simple (which is what I need) javascript clock that displays the current user's time. However, I would like to create a second clock to go right with it that will display the current time in London (GMT-0). Here's the code I currently have: <script type="text/javascript"> function createtime() { var time = new Date() var hours = time.getHours() var minutes = time.getMinutes() var seconds = time.getSeconds() var abbrev = "AM" if (hours>=12) abbrev="PM" if (hours>12) { hours=hours-12 } if (hours==0) hours=12 if (minutes<=9) minutes="0"+minutes if (seconds<=9) seconds="0"+seconds var ctime=""+hours+":"+minutes+":"+seconds+" "+abbrev+"" if (document.all) document.all.clock.innerHTML=ctime else if (document.getElementById) document.getElementById("clock").innerHTML=ctime else document.write(ctime) } if (!document.all&&!document.getElementById) createtime() function loadtime() { if (document.all||document.getElementById) setInterval("createtime()",1000) } </script> <body onLoad="loadtime()"> <center><font size="1.5">Your Time: <span id="clock"></span></font> This clock works perfectly for displaying the current time based upon the viewer's PC clock. I'm sure it can't be too difficult to add a clock that displays the time in London. If it can help, there is this clock that looks great and displays multiple timezones (surely by just adding or subtracting from the user's current clock. whatever needs to be done..) http://www.arachnoid.com/lutusp/worldclock.html the source is also available there as well. Thanks folks, Quote Link to comment Share on other sites More sharing options...
Strygun Posted August 24, 2007 Author Share Posted August 24, 2007 *bump* anyone interested in offering some help here? How can I get this clock to display GMT? Quote Link to comment Share on other sites More sharing options...
HomerTheDragoon Posted August 24, 2007 Share Posted August 24, 2007 I'd use php for getting the London time. Since the user's time zone isnt a constant. But Your webserver is. Quote Link to comment Share on other sites More sharing options...
Strygun Posted August 24, 2007 Author Share Posted August 24, 2007 But will a php clock actually "tick"? That's why I was using javascript - so I could get a real-time, ticking clock. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.