Jump to content

Making two clocks


Strygun

Recommended Posts

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,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.