Results 1 to 7 of 7

Thread: PHP Wait timer?

  1. #1
    Join Date
    Mar 2010
    Posts
    202

    PHP Wait timer?

    Hello,
    I am trying to write a code where I can use wait timer function in PHP. I have tried it but no success yet. so, if you guys have any idea then please let me know. Thank you for your help.

  2. #2
    Join Date
    Nov 2009
    Posts
    330

    Re: PHP Wait timer?

    Hello,
    Check out this code
    Code:
    <?php
    
    $lgn = time();
    $gtusr = mysql_query("SELECT * FROM `users` WHERE `users`.`id` = '$MyId'");
    $usrinf = mysql_fetch_assoc($gtusr);
    $lstlgn = $usrinf['lstlgn'] - $lgn;
    
    echo "Logged in as: " . $usrinf['username'];
    echo "Last logged in: " . $lstlgn;
    echo "PMs: ".$unread." unread, ".$read." read";
    
    ?>

  3. #3
    Join Date
    Nov 2009
    Posts
    335

    Re: PHP Wait timer?

    Hello,
    Try this code, though I am not sure that this is what you need
    Code:
    <?php
    if(!$sql){
    echo 'There has been an Error for Submitting your request. Please Contact the Web Master.';
    }else{
    echo "Hello <u><b>".$name."</b></u>";
    echo '<br/><hr>Thank you';
    echo '<br/><br/>process is under request 
    sleep(5);
    echo '<script><!-- window.location= "addresshere" //--></script>';
    }

  4. #4
    Join Date
    Nov 2009
    Posts
    518

    Re: PHP Wait timer?

    Hello,
    Just try this
    Code:
    <?php
    
    this is the current time
    echo date('h:s:i') . "\n";
    
    time seconds for 10 
    sleep(10);
    
    this is where you wake up 
    echo date('h:s:i') . "\n";
    
    ?>

  5. #5
    Join Date
    Nov 2009
    Posts
    335

    Re: PHP Wait timer?

    Hello,
    If you need then you can have a look at the following code
    Code:
    function stopWatch($total = false,$reset = true){
        global $frscld;
        global $lstcld;
        $nwtm = microtime(true);
        if ($lstcld === null) {
            $lstcld = $nwtm;
            $frscld = $nwtm;
        }
        if ($total) {
            $time_diff = $nwtm - $frscld;
        } else {
            $time_diff = $nwtm - $lstcld;
        }
        if ($reset)
            $lstcld = $nwtm;
        return $time_diff;
    }

  6. #6
    Join Date
    Nov 2009
    Posts
    343

    Re: PHP Wait timer?

    Hello,
    Alternatively you can try this
    Code:
    <?php
    srt();
    
    ob_implicit_flush(true);
    //[ OR ] echo "..."; flsh(); flush();
    
    set_time_limit(0);
    
    function sleep_echo($secnds) {
        $secnds = (int) $secnds;
        $buff = str_repeat(".", 4096);
        //echo $buff."\r\n<br />\r\n";
        for ($i=0; $i<$secnds; $i++) {
            echo date("H:i:s", time())." (".($i+1).")"."\r\n<br />\r\n".$buff."\r\n<br />\r\n";
            flsh();
            flush();
            sleep(1);
            //usleep(1000000);
        }
    }

  7. #7
    Join Date
    Nov 2009
    Posts
    330

    Re: PHP Wait timer?

    Hello,
    Just take a look at the following code
    Code:
    <?php sip(0.5); ?>
    
    <?php
    function sip($scnds)
    {
        $scnds = abs($scnds);
        if ($scnds < 1):
           usleep($scnds*1000000);
        else:
           sleep($scnds);
        endif;   
    }
    ?>

Similar Threads

  1. timer app required
    By Justin_Bieber in forum Windows Software
    Replies: 5
    Last Post: 23-02-2013, 10:59 AM
  2. Add Timer in c#
    By JasonWung in forum Software Development
    Replies: 1
    Last Post: 18-04-2012, 06:21 PM
  3. Sharepoint (MOSS) timer jobs and the timer service
    By MahaGuru in forum Office Setup
    Replies: 2
    Last Post: 01-03-2011, 09:08 AM
  4. how timer work in c#
    By Visala28 in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 11:01 AM
  5. Shutdown Your PC With a Timer
    By Aadi in forum Guides & Tutorials
    Replies: 5
    Last Post: 11-10-2008, 06:15 PM

Tags for this Thread

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
  •  
Page generated in 1,718,243,048.68897 seconds with 17 queries