Jump to content

[SOLVED] countdown timer refreshing itself every second.


Recommended Posts

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>";

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

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..

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.