thyscorpion Posted September 21, 2007 Share Posted September 21, 2007 hi, i wrote this code for the time.. but i cant seem to find a way to refresh the time left values every second ( as a real time timer) Please help.. // Define your target date here $targetYear = 2007; $targetMonth = 10; $targetDay = 23; $targetHour = 12; $targetMinute = 00; $targetSecond = 00; // End target date definition $targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear); // Define date format $dateFormat = "Y-m-d H:i:s"; $targetDateDisplay = date($dateFormat,$targetDate); $actualDateDisplay = date($dateFormat,$actualDate); echo "<br><br><center><p>Target Date decided: ".$targetDateDisplay."</p><br><br>"; echo "<div id=\"ccolor\">"; $actualDate = time(); $secondsDiff = $targetDate - $actualDate; $remainingDay = floor($secondsDiff/60/60/24); $remainingHour = floor(($secondsDiff-($remainingDay*60*60*24))/60/60); $remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60); $remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60)); echo "<font color=red size=4> $remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds </font></center>"."<br>"; echo "</div>"; Quote Link to comment https://forums.phpfreaks.com/topic/70202-solved-countdown-timer-refreshing-itself-every-second/ Share on other sites More sharing options...
MmmVomit Posted September 21, 2007 Share Posted September 21, 2007 This sounds like a job for JavaScript. http://www.javascript-page.com/clock.html Quote Link to comment https://forums.phpfreaks.com/topic/70202-solved-countdown-timer-refreshing-itself-every-second/#findComment-352605 Share on other sites More sharing options...
Crew-Portal Posted September 21, 2007 Share Posted September 21, 2007 if you dont want javascript replace your body tag with <body onLoad="setTimeout('location.reload()', 1000)"> Then it should refresh ever second! Oops wait I do believe this is javascript oops! ROFL ROFL ROFL ROFL ROFL ROFL ROFL ROFL ROFL ROFL Quote Link to comment https://forums.phpfreaks.com/topic/70202-solved-countdown-timer-refreshing-itself-every-second/#findComment-352608 Share on other sites More sharing options...
Psycho Posted September 21, 2007 Share Posted September 21, 2007 Well, you could use the META refresh property, but why? This is definitely a JS solution. Quote Link to comment https://forums.phpfreaks.com/topic/70202-solved-countdown-timer-refreshing-itself-every-second/#findComment-352610 Share on other sites More sharing options...
thyscorpion Posted September 21, 2007 Author Share Posted September 21, 2007 This sounds like a job for JavaScript. http://www.javascript-page.com/clock.html hi, thanks.. just wanted to ask one more thing.. i see i can get hrs mins and secs from the tdate.gethours() etc functions.. what is the function to get the date ( day month year) cause i need to negate it to the target date and then show the countdown.. Quote Link to comment https://forums.phpfreaks.com/topic/70202-solved-countdown-timer-refreshing-itself-every-second/#findComment-352617 Share on other sites More sharing options...
thyscorpion Posted September 22, 2007 Author Share Posted September 22, 2007 Thanks guys i figured it out. :-) using java script! :-D Quote Link to comment https://forums.phpfreaks.com/topic/70202-solved-countdown-timer-refreshing-itself-every-second/#findComment-352749 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.