Return to Snippet

Revision: 1646
at November 1, 2006 22:36 by SunnyJim


Initial Code
<?
// enter start date below like this: "January 2, 2001"
$start = "January 29, 2002";
// enter string of what this start date is.
$text = "have passed since I had a fulltime job.";

//--------------------------
$now = strtotime ("now");
$then = strtotime ("$start");
$difference = $now - $then ;
$num = $difference/86400;
$days = intval($num);
$num2 = ($num - $days)*24;
$hours = intval($num2);
$num3 = ($num2 - $hours)*60;
$mins = intval($num3);
$num4 = ($num3 - $mins)*60;
$secs = intval($num4);
?>

<p>
<? echo $days ?> days,
<? echo $hours ?> hours,
<? echo $mins ?> minutes,
<? echo $secs ?> seconds
<? echo $text ?>
</p>

Initial URL
http://www.scriptygoddess.com/archives/2002/05/23/count-up-timer-in-php/

Initial Description
I've been using a Javascript to do the same thing for years but have always wanted to do the same thing in PHP -- just never got around to writing it. Fortunately, ScriptyGoddess did it for me. Haven't actually implemented it but it looks like it should work.

Initial Title
Countup from a Date

Initial Tags

                                

Initial Language
PHP