www.webdeveloper.com
Results 1 to 3 of 3

Thread: ineed help in this code

Hybrid View

  1. #1
    Join Date
    Nov 2011
    Posts
    35

    Exclamation ineed help in this code

    whats wrong here why hours back to zero every time?

    $time_def=$current_time-$time;
    if($time_def>=15){
    $totalmin=$minute+(int)($time_def/15);
    if($totalmin>60){
    $totalhour=$hour+(int)($totalmin/60);
    $totalmin=0;
    }

    if($totalhour>24){
    $totalday=$day+(int)($totalhour/24);
    $totalhour=0;
    }

    $up=mysql_query("update time set
    day='$totalday'
    ,hour='$totalhour'
    ,minute='$totalmin'
    ,sec='$sec'
    ,time='".time()."'
    where id = '1'");
    }

  2. #2
    Join Date
    Jun 2010
    Posts
    16
    Without more code its difficult to know what you are trying to do. However, I have put together some sample code that you can run from a command line. Perhaps it will give you some ideas.

    PHP Code:
    <?php

    define 
    ('TIME_LIMIT'15);
    date_default_timezone_set('Europe/London');

    $time time();
    echo 
    "time [$time]" PHP_EOL;

    $sleep_ret sleep(TIME_LIMIT);
    if (
    $sleep_ret != 0) {
       die (
    "error: sleep returned non-zero" PHP_EOL);
    }

    $current_time time();
    echo 
    "current_time [$current_time]" PHP_EOL;

    $time_diff $current_time $time;

    if (
    $time_diff >= TIME_LIMIT) {
       echo 
    "time limit exceeded" PHP_EOL;

       
    $time_diff_array =  explode(',' strftime ("%H,%M,%S"$time_diff));

       
    print_r ($time_diff_array);

       
    # use zero base for hours
       
    echo "total hours [". ($time_diff_array[0]-1) . "]" PHP_EOL;
       echo 
    "total minutes ["$time_diff_array[1] . "]" PHP_EOL;
       echo 
    "total seconds ["$time_diff_array[2] . "]" PHP_EOL;
    }

    ?>
    Last edited by dukesdemise; 05-04-2012 at 11:55 AM.

  3. #3
    Join Date
    Nov 2011
    Posts
    35

    Thank you

    Thank you for your reply but isolved problem after ipost this topic
    if($totalmin>60){$totalmin=0;}else{$totalmin=$minute} iforget add (else) itry make mmo 1day in my mmo=6 hour thats mean 1 minute in my game=15 second my code work good now

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles