var refreshInterval = 60000; //60 seconds var serverTimeOffset = -5; var localTimeAtLoad = new Date(); var timeAdjust = (localTimeAtLoad.getTimezoneOffset() / 60) + serverTimeOffset; //hours function runCountdown(){ currentTime = new Date(); //local time currentESTHour = currentTime.getHours() + timeAdjust; //24-hour time displayHours = (currentESTHour > 12) ? currentESTHour - 12 : currentESTHour; displayMinutes = (currentTime.getMinutes() < 10) ? "0" + currentTime.getMinutes() : currentTime.getMinutes(); displayTime = displayHours + ":" + displayMinutes + " EST"; rowDate = new Date(); timeRows = $("#todaysShowsTable tr"); numRows = timeRows.length; keepLooking = true; for(var i = 0; i 0 && keepLooking){ var minutes = Math.floor(timeDiff % 60); //this used to be round() instead of floor() var hours = Math.floor(timeDiff / 60); var timeStr = ""; if(hours > 1){ timeStr += hours.toString() + " hours"; }else if(hours == 1){ timeStr += hours.toString() + " hour"; } if(minutes > 1){ if(hours > 0){timeStr += " and ";} timeStr += minutes.toString() + " minutes"; }else if(minutes == 1){ if(hours > 0){timeStr += " and ";} timeStr += minutes.toString() + " minute"; } var message = 'Next show in '+timeStr+''; keepLooking = false; } if(keepLooking){ //no shows left today var message = 'Next show tomorrow'; } } } $("#countdownTimer").html(message); $("#timeEST").html('Currently '+ displayTime +''); } function refreshData(){ if($("#todaysShowsTable")){ runCountdown(); //start countdown timer to next show } $("#onAirInfo").load("includes/onair_ajax.php", function(response, status, xhr){ if(status == "error"){ $("#onAirInfo").html('Error: Could not load content.'); } }); } $(document).ready(function(){ refreshData(); //initialize data setInterval(refreshData, refreshInterval); //refresh once/minute });