Joe Bills Joe Bills - 6 months ago 26
PHP Question

How would I Get User Online or Offline Using Timestamp?

So I Have this code i would like to use to get Online or Offline status for use of a profile page. I can not seem to get the correct information. It shows as Online all the time, Or if i

it, Comes out as Offline.

<?php if($row['time'] >= 600) { echo "Online"; } else {echo "Offline"; }?>

Thank you!


Try this

<?php $timestamp = strtotime($row['time']);

if($timestamp >= time()-20) { echo "Online"; } else {echo "Offline"; }

Note: 20 is in seconds