/    Sign up×
Community /Pin to ProfileBookmark

Timezone Offset

Hi, I have the following script which counts down to an onair date and time of 18th June at 3pm for my radio show. International visitors visit my site and therefore the time is 3pm their time and not GMT. How can I make this so that the time is read as GMT all the time, by everyone.
This code has been slightly edited by myself from the original by Dynamic Drive to make it say 1 [B]day[/B] not days and to delete the days, etc when there are 0 days left.

[code=php]
//Dynamic countdown Script II- © Dynamic Drive ([url]www.dynamicdrive.com[/url])
//Support for hour minutes and seconds added by Chuck Winrich ([email protected]) on 12-12-2001
//For full source code, 100’s more DHTML scripts, visit [url]http://www.dynamicdrive.com[/url]

function setcountdown(theyear,themonth,theday,thehour,themin,thesec){
yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec
}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day, hour(0=midnight,23=11pm), minutes, seconds:
setcountdown(2004,06,18,15,00,00)

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion=”Next Show”
var message_on_occasion=”<font color=’white’ size=’3′>On Air NOW</font><br>3pm-4pm”

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth=’140px’
var countdownheight=’70px’
var countdownbgcolor=’#1F1F40′
var opentags='<font face=”Verdana” size=”2″>’
var closetags='</font>’

//////////DO NOT EDIT PAST THIS LINE//////////////////

var montharray=new Array(“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”)
var crosscount=”

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility=”show”
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById(“countdownie”) : countdownie
countdown()
}

if (document.all||document.getElementById)
document.write(‘<span id=”countdownie” style=”width:’+countdownwidth+’; background-color:’+countdownbgcolor+'”></span>’)

window.onload=start_countdown

function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+” “+todayd+”, “+todayy+” “+todayh+”:”+todaymin+”:”+todaysec
futurestring=montharray[mo-1]+” “+da+”, “+yr+” “+hr+”:”+min+”:”+sec
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//hour is 1 hour, hours if more than 1 hour
if(dhour<2&&dhour>=1){
hourtext=”hour”
}
else
hourtext=”hours”

//minute is 1 minute, minutes if more than 1 minute
if(dmin<2&&dmin>=1){
mintext=”minute”
}
else
mintext=”minutes”

//second is 1 second, seconds if more than 1 second
if(dsec<2&&dsec>=1){
sectext=”second”
}
else
sectext=”seconds”

//day is 1 day, days if more than 1 day
if(dday<2&&dday>=1){
daytext=”day”
}
else
daytext=”days”

//if same hour of time of occasion but on same day
if(dhour<=0&&dhour>=-1&&dmin<=0&&dsec<=0&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
//if 1hr after time of occasion but on same day
else if(dhour<-1&&dmin<=0&&dsec<=0&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+””+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+””+closetags
return
}

//if passed day of occasion
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+””+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+””+closetags
return
}
//else, if not yet no days no hours no minutes
else if (dday<1&&dday>=0&&dhour<1&&dhour>=0&&dmin<1&&dmin>=0){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+ “<font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+ ” <font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags
}
//else, if not yet no days no hours
else if (dday<1&&dday>=0&&dhour<1&&dhour>=0){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+ “<font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dmin+” “+mintext+”<br>and “+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+ ” <font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dmin+” “+mintext+”<br>and “+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags
}
//else, if not yet no days
else if (dday<1&&dday>=0){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+ “<font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dhour+” “+hourtext+”, <br>”+dmin+” “+mintext+”<br>and “+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+ ” <font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dhour+” “+hourtext+”, <br>”+dmin+” “+mintext+”<br>and “+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags
}
//else, if not yet
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+ “<font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dday+ ” “+daytext+”,<br>”+dhour+” “+hourtext+”, <br>”+dmin+” “+mintext+”<br>and “+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+ ” <font color=white size=’3′>Countdown to<br>Next Show</font><br>”+dday+ ” “+daytext+”,<br>”+dhour+” “+hourtext+”, <br>”+dmin+” “+mintext+”<br>and “+dsec+” “+sectext+”<br><font face=’Verdana’ color=’#FFFFFF’ size=’1′><span style=’font-weight: 700′>(only correct for UK) </span></font>”+closetags
}
setTimeout(“countdown()”,100)
}
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Jun 14.2004 — Considering that users can set their computer time to whatever they want, you really can't control that. The only thing that I recommned doing is passing the UTC date to your web page through a server side language. Then, you can configure your page based on that value, not the user's PC timestamp.
×

Success!

Help @stevoradio 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.28,
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,
)...