The previous php file I posted returned the GMT time. If you want it to return local time, use this PHP file named servertime.php insteadYou can check if it works by viewing the file you uploaded to the server in your webbrowser. It should display a numeric value.Code:<? echo time() + date("Z") ; ?>
Modified ActionScript code to use the server time for a countdownCode:ServertimeUrl = 'servertime.php?' + 1 * new Date(); addToTimer = 0; lv = new LoadVars(); lv.onData = function(v) { if (v != undefined) { addToTimer = 1000 * v - getTimer(); } } lv.load(ServertimeUrl); oneHour = 3600000; onEnterFrame = function() { if (addToTimer) { serverTime = getTimer() + addToTimer; zeroHundred = 86400000 * Math.floor(serverTime / 86400000); todayEightAM = zeroHundred + 8 * oneHour; todayTenAM = zeroHundred + 10 * oneHour; tomorrowEightAM = zeroHundred + 32 * oneHour; if (serverTime < todayEightAM) { remaining = todayEightAM - serverTime; // offer that started yesterday } else if (serverTime > todayTenAM) { remaining = tomorrowEightAM - serverTime; // offer that started today } else { remaining = 0; // no offer at this time } if (remaining){ remainingSeconds = Math.floor(remaining / 1000); remainingMinutes = Math.floor(remainingSeconds / 60); remainingHours = Math.floor(remainingMinutes / 60); remainingSeconds -= remainingMinutes * 60; remainingMinutes -= remainingHours * 60; txt1.text = 'Countdown : ' + remainingHours + 'h '; txt1.text += remainingMinutes + 'm ' + remainingSeconds + 's'; } else { txt1.text = 'No offer at this time'; } } }




Reply With Quote