Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 35

Thread: time converter

  1. #21
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    PHP Code:
    <?php
    function secondsConvert($time){
      
    $seconds explode(':'$time);
      
    $total_seconds 0;
      
    $total_seconds += $seconds[0] * (60 60);
      
    $total_seconds += $seconds[1] * 60;
      
    $total_seconds += $seconds[2];
      return 
    $total_seconds;
    }
    $time date("H:i:s");
    echo 
    secondsConvert($time)." seconds"
    ?>
    secondsConvert will return (hours*60*60)+(minutes*60)+seconds.
    Jeremy | jfein.net

  2. #22
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    how to do with date?

  3. #23
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Well - for days, that would just be day * 24 * 60 * 60, but for months and years, it'd be hard because there aren't always four weeks in a month...
    Jeremy | jfein.net

  4. #24
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    how to create difference then?

    can I use $time - $timet = 300seconds ?

    OR

    if (($time - $timet) >= '00:05:00') then {echo "he is online";}
    Last edited by auriaks; 01-05-2010 at 11:04 PM.

  5. #25
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    How to do something like that?

  6. #26
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    What do you mean? Can't you just insert names of the people online, and when the user logs out, there not online?
    Jeremy | jfein.net

  7. #27
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    But sometimes people dont push log out and name would be still there

  8. #28
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Hmm.. So every time the user goes somewhere, have a field for each user called "Minute" and insert the current minute. Then, when every user refreshes the page, it checks each users minutes, and if its more then 5 minutes idle, delete them from the list. (also, make sure 61 = 0, 62 = 1...)
    Jeremy | jfein.net

  9. #29
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    Will this work even then when they close their browsers??

  10. #30
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Yes - 5 minutes after they close the browser, they shold be off the list.
    Jeremy | jfein.net

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
  •