Edit: Sorry, just noticed there is a subforum for Java requests - My bad.Hi everybody
First let me tell you what this is about:It's a simple countdown script which makes it possible to me/us to track an event and of course when it's about to start, once the counter reaches zero it resets itself.
Example:Friday, 9pm - Shows me the days, hours, minutes and seconds left - As soon as the timer hits the given day and time it resets and counts until we reach the next Friday and so on.
What I need:Java refers to the user's local time, which doesn't help at all as we are having different time zones - Is there any way that some of you may change the script to just
stick to one fixed Timezone? (Like GMT)
(Yes i googled a lot and no, I haven't found a fix) - Java seems to be Client based as can be.. There must be some kind of workaround though.
You can imagine it doesn't make sense if I organize an event living in a GMT+2 zone and people from Australia get there like 8 or 10 hours later
I'm not into coding nor programming anymore so I'd really appreciate your help
Thanks in advance for your time
Here's the complete code:Code
<html>
<head>
<script type = "text/javascript">
var cday;
var timeInSecs;
var ticker;
function getSeconds() {
var now = new Date();
var nowtime= now.getTime(); // time now in milliseconds
var countdowntime = new Date(now.getFullYear(),now.getMonth(),now.getDate(),21,0,0); // 16 hrs = 4 pm
// countdowntime - change time hh,mm,ss to whatever time required, e.g. 7,50,0 (0750)
var dy = 5 ; // Friday (day 5) - change for other days 0-6
var atime = countdowntime.getTime();
var diff = parseInt((atime - nowtime)/1000); // positive if date is in future
if (diff >0) {
cday = dy - now.getDay();
}
else {
cday = dy - now.getDay() -1;
}
if (cday < 0) { cday += 7; } // aleady passed countdown time, so go for next week
if (diff <= 0) { diff += (86400 * 7) }
startTimer (diff);
}
function startTimer(secs) {
timeInSecs = parseInt(secs);
ticker = setInterval("tick()",1000);
tick(); // to start counter display right away
}
function tick() {
var secs = timeInSecs;
if (secs>0) {
timeInSecs--;
}
else {
clearInterval(ticker); // stop counting at zero
getSeconds(); // and start all over again!
}
var days = Math.floor(secs/86400);
secs %= 86400;
var hours= Math.floor(secs/3600);
secs %= 3600;
var mins = Math.floor(secs/60);
secs %= 60;
var result = "Time remaining " + cday +' day(s) ';
result += ((hours < 10 ) ? "0" : "" ) + hours + " hours " + ( (mins < 10) ? "0" : "" ) + mins
+ " minutes " + ( (secs < 10) ? "0" : "" ) + secs + " seconds";
document.getElementById("countdown").innerHTML = result;
}
</script>
</head>
<body onload = "getSeconds()">
<span id="countdown" style="font-size: 20; font-weight:bold;" > </span>
<p><span style="margin-right: 10px;"><span id="circle-days" class="circle-time">
</span><span id="circle-hours" class="circle-time"></span>
<span id="circle-minutes" class="circle-time"></span>
<span id="circle-seconds" class="circle-time"></span></span><span id="timer">
</span></p>
</body>
</html>
This post was edited by Bl4cKDeviL on Apr 21 2018 05:16am