Trying to check if a user was logged in less 4 hours prior to current time based of a mysql DATETIME column. Can anyone suggest a better way? I'm having a hard time wrapping my head around all the date functions.
function isOnline($lasLogin){
$curTime = date("Ymdhi", strtotime(date("Y-m-d h:i:s")));
$lasLogin = date("Ymdhi", strtotime($lasLogin));
$diff = $curTime - $lasLogin;
if($diff < 9220){
return true;
} else {
return false;
}
}
Thanks 🙂