-
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.
-
-
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...
-
how to create difference then?
can I use $time - $timet = 300seconds ?
OR
if (($time - $timet) >= '00:05:00') then {echo "he is online";}
-
How to do something like that?
-
What do you mean? Can't you just insert names of the people online, and when the user logs out, there not online?
-
But sometimes people dont push log out and name would be still there
-
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...)
-
Will this work even then when they close their browsers??
-
Yes - 5 minutes after they close the browser, they shold be off the list.