Count Down To New Year As Its Neally Xmass Lol
Started on the old forum in November 2008 · view the original in the archive · old links redirect here
or if you wanted to be a little more posh about it
function timeAgo($time) {
$diff = $time-time();
$daysDiff = floor($diff/60/60/24);
$diff -= $daysDiff*60*60*24;
$hrsDiff = floor($diff/60/60);
$diff -= $hrsDiff*60*60;
$minsDiff = floor($diff/60);
$diff -= $minsDiff*60;
$secsDiff = $diff;
return ($daysDiff > 0 ? $daysDiff."day".($daysDiff > 1 ? "s ":" "): "").($hrsDiff > 0 ? $hrsDiff."hr".($hrsDiff > 1 ? "s ":""): " ").($minsDiff > 0 ? $minsDiff."min".($minsDiff > 1 ? "s ":" "): "").($secsDiff > 0 ? $secsDiff."sec".($secsDiff > 1 ? "s ":" "): "");
}
$eventtime = mktime(0,0,0,12,25,2008);
$remain = timeAgo($eventtime);
echo(time() < $eventtime ? "$remain left until christmas" : (time() >= $eventtime && time() < ($eventtime + 86400) ? "Merry Christmas!" : "Hope you all enjoyed your christmas"));
thats for xmas but easily changeable to whatever you want .
change the mktime() of $eventtime to the date/time the special event is .. which in this case is 12:00am 25th DEC 2008
now just modify you echo statement. the first bit of text is to display how long is left if the event has not reached yet. the second is merry christmas as the event is here and teh last is hope you enjoyed your xmas as it as past .. you will notice the + 86400 this adds a day onto the eventtime so that we can check if the event has past and we are now on another day .. obviously if you were counting down to 3 mins of silence for those lost in the war then you would only need + 180 so after 3 mins it says it has past the 3 mins
pretty simple really 🙂
very nice djlee 🙂 but at mine not work very well:
44days 5hrs 14mins 8secs left until christmas
Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\htdocs\tecweb\core.php:806) in C:\xampplite\htdocs\tecweb\index.php on line 19
Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\htdocs\tecweb\core.php:806) in C:\xampplite\htdocs\tecweb\index.php on line 21
Hate romains that take codes from here and tell to all that they had made that External image (may be gone)
QUOTE (ionutxp @ Nov 10 2008, 05:45 PM) <{POST_SNAPBACK}>
very nice djlee 🙂 but at mine not work very well:
44days 5hrs 14mins 8secs left until christmas Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\htdocs\tecweb\core.php:806) in C:\xampplite\htdocs\tecweb\index.php on line 19 Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\htdocs\tecweb\core.php:806) in C:\xampplite\htdocs\tecweb\index.php on line 21
i dont thnk that this warnings have something to do with the code posted by djlee, its has more to do with the code where you gave placed it "core.php".
Advertise your mobile site for FREE with AdTwirl