/    Sign up×
Community /Pin to ProfileBookmark

Multiple Clocks in one page

Hi Guys

I need to put 4 clocks into one html page. However the problem is they all need to be displaying different time zones. How can I do that with one script? Does anybody have a script that can do that?

They all need to be displaying at the same time.

Also, how do you set a clock back say 6 hours so when its 12.00 the clock will say its only 6.00.

Thanks

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@kinkFeb 05.2006 — <html>

<head>


<script type="text/javascript">

function twxfunction()

{


var re = new Date();

setTimeout("twxfunction()",1000)

var hys = re.getHours();

var myn = re.getMinutes();

var sec = re.getSeconds();

if (sec < 10)(sec = "0" + sec);

if (myn < 10)(myn = "0" + myn);

if (hys < 10)(hys = "0" + hys);

var h = document.drw.da.value;


document.drw.da.value = hys + ":" + myn + ":" + sec ;

var tmz = hys - 6 * 1;

document.drw.dax.value = tmz + ":" + myn + ":" + sec ;

var tmzo = tmz - 6 *
1;

document.drw.daxo.value = tmzo + ":" + myn + ":" + sec ;

var tmzon = tmzo - 6 * 1;

document.drw.daxon.value = tmzon + ":" + myn + ":" + sec ;







}

</script>

</HEAD>

<BODY onload="twxfunction()">



<form name="drw" action="none">

<input type="text" id="tb" name="da" value="hello">

<input type="text" id="tb" name="dax" value="hello">

<input type="text" id="tb" name="daxo" value="hello">

<input type="text" id="tb" name="daxon" value="hello">

</form>

</BODY>

</HTML>
Copy linkTweet thisAlerts:
@peakymattauthorFeb 05.2006 — Thanks for that script. your a champ.

However, I need to be able to change the time in 30 minute increments, not just hourly. How would I change that?
Copy linkTweet thisAlerts:
@kinkFeb 06.2006 — im no mathemetician but this is close

<script type="text/javascript">

function twxfunction()

{


var re = new Date();

setTimeout("twxfunction()",1000)

var hys = re.getHours();

var myn = re.getMinutes();

var sec = re.getSeconds();

if (sec < 10)(sec = "0" + sec);

if (myn < 10)(myn = "0" + myn);

if (hys < 10)(hys = "0" + hys);

var h = document.drw.da.value;


document.drw.da.value = hys + ":" + myn + ":" + sec ;

var tmz = hys - 6 * 1;

document.drw.dax.value = tmz + ":" + myn + ":" + sec ;

var tmzo = tmz - 6 *
1;

document.drw.daxo.value = tmzo + ":" + myn + ":" + sec ;

var tmzon = tmzo - 6 * 1;

document.drw.daxon.value = tmzon + ":" + myn + ":" + sec ;


if(sec === 60)sec = "59";

var rs = sec * 1 + 30 * 1;

var nt = sec * 1 - 30 * 1;

if(sec < 31)document.drw.m.value = rs;

else

document.drw.m.value = nt;

if(myn === 60)myn = "59";

var rsn = myn * 1 + 30 * 1;

var ntn = myn * 1 - 30 * 1;

if(myn < 31)document.drw.mn.value = rsn;

else

document.drw.mn.value = ntn;


}

</script>







<form name="drw" action="none">

<input type="text" id="tb" name="da" value="hello">

<input type="text" id="tb" name="dax" value="hello">

<input type="text" id="tb" name="daxo" value="hello">

<input type="text" id="tb" name="daxon" value="hello">

<input type="text" id="tb" name="m" value="hello">

<input type="text" id="tb" name="mn" value="hello">

</form>
Copy linkTweet thisAlerts:
@gphFeb 06.2006 — Displaying time zones is a bit more complicated than you might expect.

First you need to find where in the world the computer is. If the computer is set correctly, you can use obj.getTimezoneOffset. But then, what about daylight savings time?

The only reliable way to do this is from the server, maybe with AJAX though every second might be quite a load.
×

Success!

Help @peakymatt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...