I'm attempting to see if a time is within the last hour.
$unit_date = date($unit['last_accessed'], 'Y-m-d H:i:s');
$last_hour = date('Y-m-d H:i:s', strtotime('-1 hour'));
if($unit_date >= $last_hour ){
$connect = "<i class='fa fa-circle 2x' style='color:#2ECC71;'></i>";
} else {
$connect = '';
}
As you can see I'm putting $unit['last_accessed'] into the correct format then comparing to an hour ago. If the time is within the last hour $connect is a font awesome circle (colored green), if it's not within the last hour it's empty, right now it's saying nothing is within the last hour which is false.