Countdown Scripts, we all need one somewhere, even if it just until our next birthday :P So, here's mine:
<?phpfunction countdown ($count) {$difference = $count - time();$abs_difference = abs($difference); $days = floor($abs_difference/60/60/24);$hours = floor(($abs_difference - $days*60*60*24)/60/60); $minutes = floor(($abs_difference - $days*60*60*24 - $hours*60*60)/60); if ($difference != $abs_difference) {return "It was $days days, $hours hours and $minutes minutes ago!";} else {return "Only $days days, $hours hours and $minutes minutes to go!";} }?>To use it, you pass a *nix timestamp in the function call, eg. countdown (1108774476);
Remember you can also use the mktime function, eg. countdown (mktime (3, 20, 0, 4, 20, 1992));
Lastly, it returns the string, it doesn't output it, so to output it you'll need to use echo or print, eg. echo countdown (1108774867);
Comments
There aren't any comments yet, but feel free to leave one regardless.