<script>
var tId="";
var anHour = 60*60*1000;
var twoHours = anHour*2
var localTime = new Date();
var serverTime = new Date(localTime.getTime());
serverTime.setHours(17);
var diff = serverTime.getTime()-localTime.getTime();
function countDown() {
var text = "";
var now = new Date();
// var gmt = new Date(now.getTime() + (now.getTimezoneOffset() * 60000));
var serverTime = new Date(now.getTime()+diff)
var seventeen = new Date(serverTime.getFullYear(),serverTime.getMonth(),serverTime.getDate(),17,0,0,0);
var nineteen = new Date(seventeen.getTime()+twoHours);
if (serverTime>=seventeen&&serverTime<=nineteen) text += " - We are out for dinner";
var millisecsUntilSeventeen =seventeen.getTime()-serverTime.getTime();
var millisecsUntilNineteen =nineteen.getTime()-serverTime.getTime();
if (millisecsUntilSeventeen<0) {
seventeen.setDate(seventeen.getDate()+1);
}
var millisecsUntilSeventeen =seventeen.getTime()-serverTime.getTime();
var ss = Math.floor(millisecsUntilSeventeen/1000);
millisecsUntilSeventeen = millisecsUntilSeventeen % 1000;
var mm = Math.floor(ss/60);
ss = ss % 60
var hh = Math.floor(mm/60);
mm = mm % 60;
if (mm<10) mm="0"+mm
if (ss<10) ss="0"+ss
text = 'Countdown to 17:00: '+hh+':'+mm+':'+ss+'<br>It is '+serverTime+' - Our time<br>It is '+now+' - your time<br>'+text
document.getElementById('timeSpan').innerHTML=text;
}
window.onload=function() { tId=setInterval('countDown()',1000);}
</script>
<span id="timeSpan" style="position:fixed; top:0;left:500"></span>
|