SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: PHP Countdown

  1. #1
    SitePoint Enthusiast COMpWiZkEv's Avatar
    Join Date
    Jul 2002
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP Countdown

    How could I make a countdown counter with PHP?

    For Example:
    There are X days left until Christmas

  2. #2
    o_O O_o BlueFire2k5's Avatar
    Join Date
    Mar 2003
    Location
    Sioux Falls, SD
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it would be easier to do this in Javascript. At least, thats the only way I've seen it done.

    (You want it to be dynamic like a real clock and not static on the page and refresh everytime someone hits refresh right?)

    Edit: Ahh, you want days left, I was thinking something like this...

    http://www.max-evolution.com/countdown.htm

    Anyway, I'll get my code and I'll edit this agian so you can do the days left thing.
    Last edited by BlueFire2k5; Mar 19, 2003 at 15:03.

  3. #3
    SitePoint Member sc00pb's Avatar
    Join Date
    Feb 2003
    Location
    Phoenix, Az.
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can try it using a for loop.

    for ($x=$currentDay; $x > $finalDay; $x--)
    {
    //the code you want to put here
    }
    • "The man who can't see a horse galloping on a tomatoe is an idiot." "Andre Breton"

  4. #4
    o_O O_o BlueFire2k5's Avatar
    Join Date
    Mar 2003
    Location
    Sioux Falls, SD
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $today 
    getdate(); 
    $christmas2 getdate(mktime(0,0,0,12,25,2003));
    $christmas $christmas2['yday'] - $today['yday'];
    echo 
    $christmas ." days left until Christmas <br>";
    ?>
    That should work.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •