Hello Guys,
I have a simple countdown script that countdown to a specific date. The problem is that before the event happens it read like this. "There are 200 days until your graduation" but after the event is over it reads "There are -200 days until your graduation".
How can add an if statement to the code so that after the graduation date it reads "Its been 200 after my graduation" and get rid of the negative days part.
Regards,
Johnny.
Here's the code:
PHP Countdown (Variation 2) - Contributed by Mike D
<?
$day = 1; // Day of the countdown
$month = 1; // Month of the countdown
$year = 2010; // Year of the countdown
// mktime is the marked time, and time() is the current time.
$target = mktime(0,0,0,$month,$day,$year);
$diff = $target - time();
$days = ($diff - ($diff % 86400)) / 86400;
$diff = $diff - ($days 86400);
$hours = ($diff - ($diff % 3600)) / 3600;
$diff = $diff - ($hours 3600);
$minutes = ($diff - ($diff % 60)) / 60;
$diff = $diff - ($minutes * 60);
$seconds = ($diff - ($diff % 1)) / 1;
printf("There are $days days, $hours hours, $minutes minutes, $seconds seconds until the target date and time");
?>
An example of this script in action:
There are 2095 days, 5 hours, 7 minutes, 26 seconds until the target date and time