hi all,
have some question on displaying a countdown system
i have the following code

<?php
date_default_timezone_set('Singapore');
// Define your target date here
    $targetYear   = 2011;
    $targetMonth  = 9;
    $targetDay    = 10;
    $targetHour   = 12;
    $targetMinute = 00;
    $targetSecond = 00;
// End target date definition

$targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
$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));

// Define date format
$dateFormat = "Y-m-d H:i:s";

$targetDateDisplay = date($dateFormat,$targetDate);
$actualDateDisplay = date($dateFormat,$actualDate);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<body>
 TARGET DATE : <?php echo $targetDateDisplay; ?><br/><br/>
 ACTUAL DATE : <?php echo $actualDateDisplay; ?><br/><br/>
 REMAINING   : <?php echo "$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds";?>
</body> 

and it will show this

TARGET DATE : 2011-09-10 12:00:00

ACTUAL DATE : 2011-01-03 19:58:34

REMAINING : 249 days, 16 hours, 1 minutes, 26 seconds

now i want to have a box which will show the remaining time and will auto refresh itself,what should i add to the display function?
thank for help

Recommended Answers

All 4 Replies

u can do it with javascript it have that implemented
and i m sorry i dont have that expereince in javascript to redirect ya

go and google it and u will find it

good luck

that website is using javascript as well,
actually i have the countdown function and i need to know how to create a page to show the time by calling the countdown function...
anw..thx you guys

Member Avatar for diafol

Mark it solved please.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.