<div class="row grid-margin">
    <div class="col-md-12">
        <div class="card">
            <div class="card-body">
                <h4 class="card-title">Sync</h4>
                <table id="sync_table" style="width:100%" class="table table-striped">
                    <thead>
                        <tr>
                            <td>No</td>
                            <td>User Name</td>
                            <td>Last Time</td>
                        </tr>
                        <tbody>
                            <?php 
                                $i = 1;
                                foreach($data as $row){
                                    echo "<tr>";
                                    echo "<td>{$i}</td>";
                                    echo "<td>{$row["user_name"]}</td>";
                                    $now  = time();
                                    if(isset($row["created_date"]) && $row["created_date"]!=""){
                                        date_default_timezone_set("Asia/Calcutta");
                                        $now  = time();
                                        $date = strtotime($row["created_date"]);
                                        $duration = ($now - $date)/(60 * 60);
                                        if($duration >= 72){
                                            echo "<td style='background-color:red'>{$row["created_date"]}</td>";
                                        }else if ($duration < 72 && $duration >=24){
                                            echo "<td style='background-color:yellow'>{$row["created_date"]}</td>";
                                        }else{
                                            echo "<td>{$row["created_date"]}</td>";
                                        }
                                    }else{
                                        echo "<td style='background-color:red'>&nbsp;</td>";
                                    }
                                    echo "</tr>";
                                    $i++;
                                }
                            ?>
                        </tbody>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
$(function() {
    $("#sync_table").DataTable();
});
</script>
