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

3 replies · 513 views · started 18 years ago · 1 min read

4 participants
jsyguy23 Developer · 134 posts #1

CODE $xmas=mktime(0,0,0, 01, 01, 2009); $nsec=time(); $sectx=$xmas - $nsec; if($sectx>0){ echo "$sectx Seconds to 2009 ";} else{echo "HAPPY NEW YEAR!!! ";}

djlee Developer · 224 posts #2

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 🙂

ionutxp Developer · 137 posts #3

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)

GumSlone Administrator Principal · 1,690 posts #4

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

External image (may be gone)

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close