Joe Bills Joe Bills - 2 years ago 101
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!

Answer Source

Try this

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

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

Note: 20 is in seconds

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download