Results 1 to 5 of 5

Thread: php countdown?

  1. #1
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post php countdown?

    Hey all, what i need to create is a php count down. But with the added difference of it being resetable. For example i need it to count down like a clock for say 2 weeks. Then after the 2 weeks are up, it will pause for 1 day and then start to count down 2 weeks again, ive made one in flash before but i had to specify a date which i wanted to countdown to.

    I would like to know if this is possible to do this, because like i said i have done one in flash and it requires a date, i have also seen php ones that require dates.

    If anyone can help that would be great.


    Thanks

  2. #2
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i will take a guess this isnt possible then.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP Code:
    <?
    //ignore this line %


    $time /*time*///use this to set the end date
    //ex: you could use time()+(2*7*24*60*60)
    //or specify using mktime(), etc

    $rem $time-time();

    $sec $time%(60);
    $min $time%(60*60);
    $hr $time%(60*60*24);
    $days round($time/(60*60*24));

    //do whatever now, like echo;
    ?>
    Something like that.

    This counter will not be live, so if you need it to change on the page, you'll need to use PHP to give javascript a value (just echo the PHP results into the source in the middle of the javascript to set a variable), then you could do a continuous countdown that way.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    cheers dude ill give it a shot



    EDIT * can you give a little more help?? sorry im newish (i know some but.. not much ).. to php. Or point me to a nice tut ta

    like the echo how do i echo it to show the day hour and mintue??

    Code:
    <?
    //ignore this line &#37;
    
    
    $time = time()+(2*7*24*60*60); //use this to set the end date
    //ex: you could use time()+(2*7*24*60*60)
    //or specify using mktime(), etc
    
    $rem = $time-time();
    
    $sec = $time%(60);
    $min = $time%(60*60);
    $hr = $time%(60*60*24);
    $days = round($time/(60*60*24));
    
    //do whatever now, like echo;
     {
     echo "<table>";
     echo "<tr>";
     echo "<td>" . $sec. "</td>";
     echo "<td>" . $min. "</td>";
     echo "<td>" . $hr. "</td>";
     echo "<td>" . $days. "</td>";
     echo "</tr>";
     }
    echo "</table>";
    
    ?>
    thats what i have you see and i get this www.dirttag.com/Login/counter.php
    Last edited by andy_DT; 08-10-2007 at 07:47 PM.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Er.... my math is off.

    You can probably also just use date() anyway.
    See here:
    http://www.php.net/manual/en/function.date.php

    seconds: date('s');
    min: date('i');
    hr: date('H');
    days: date('j');
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •