/    Sign up×
Community /Pin to ProfileBookmark

Gmt java Script

Gday All with the help of some of you guys out there in java script land i managed to get my time of day script working. NOw the prolem is that the script works great for system time can anyone tell me how i can edit the following code to read zulu time instead of system time. Also to only show on a specific date.

<script language = ‘JavaScript’ type=”text/JavaScript”>
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
var lim = (hours*60)+minutes;

if(lim>=(4*60+0) && lim<=(4*60+19)){
document.write(“<IMG SRC=’http://www.westairairlines.com/Cat%20Routes/images/Boarding.gif‘>”);
}
else if(lim>=(4*60+20) && lim<=(4*60+45)){
document.write(“<IMG SRC=’http://www.westairairlines.com/Cat%20Routes/images/nowboarding.gif‘>”);
}
else if(lim>=(4*60+46) && lim<=(5*60+0)){
document.write(“<IMG SRC=’http://www.westairairlines.com/Cat%20Routes/images/Departing.gif‘>”);
}
else if(lim>=(5*60+1) && lim<=(7*60+10)){
document.write(“<IMG SRC=’http://www.westairairlines.com/Cat%20Routes/images/Inflight.gif‘>”);
}
else if(lim>=(7*60+11) && lim<=(7*60+30)){
document.write(“<IMG SRC=’http://www.westairairlines.com/Cat%20Routes/images/Landed.gif‘>”);
}
else
document.write(“<IMG SRC=’http://www.westairairlines.com/Cat%20Routes/images/Closedon.jpg‘>”);
</script>

Thank you in advance

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterSep 30.2005 — Hi, Rusty073.

If you were to do this with no help from the server, these functions are what you are after:
<i>
</i>getUTCHours()
getUTCMinutes()

The only problem with this is that the user's clock can be waaaay off for their local timezone. It's best to rely on your server's clock. If you want to really get exact, you can compair your server with an atomic clock and figure out how much your server clock is off in order to return some even more accurate times.

If you already need to use your server for accuracy, might as well do your entire script on the server and forget about JavaScript, that way you can even serve the users with JavaScript disabled. All you are doing is writing an image based on the time, can't refuse serving the other 10% if it is possible -- go server side my friend.
Copy linkTweet thisAlerts:
@Rusty073authorSep 30.2005 — Thank you for the quick reply but to tell you the truth i wouldnt even know how to make a server script to perform theses actions.
Copy linkTweet thisAlerts:
@UltimaterSep 30.2005 — Then you should really look into broadening your horizons. If your server supports PHP, make a thread in the PHP forum.

Here's a simple PHP program to test wether your server supports PHP:
<i>
</i>&lt;?php
$now = time();
echo $now;
?&gt;

To see what [i]should[/i] happen when the script is run, you can see a working example off of my server:

http://www.aplustv.com/public_stuff/time.php
×

Success!

Help @Rusty073 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.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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