I've been doing a good amount of research with this, and used a few codes to get to know how to make this work, but nothing has worked the way I wanted it to, or hasn't worked at all.
The code is:
<?php $time1 = $user['last_active']; $time2 = "+5 minutes"; if (strtotime($time1) > strtotime($time2)) { echo "Online!"; }else{ echo "Offline!"; } ?> It is supposed to compare the two variables, and find out if the last active variable is greater or less than 5 minutes, and if it is greater, appear offline. I do not know what's wrong as the NOW() updates on each page and stops if the user is not logged in. Any suggestions or help? Thanks.
The $time1 variable is coming from a fetched array that gets the ['last_active'] information that updates on each page.
I fixed my code, but it still doesn't work right, however, I think I have managed to get further than I was..
<?php $first = new DateTime(); $second = new DateTime($user['last_active']); $diff = $first->diff( $second ); $diff->format( '%H:%I:%S' ); if($diff->format( '%H:%I:%S' ) > (strtotime("5 minutes"))){ echo "Offline"; }else{ echo "Online"; } ?> What can I do at this point?