<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="table-responsive">
<table id="tablaPersonas" class="table table-striped table-bordered table-condensed" style="width:100%">
<thead class="text-center">
<tr>
<th>Id</th>
<th>Nombre</th>
<th>Email</th>
<th>Telefono</th>
<th>Vencimiento</th>
<th>pago por</th>
<th>Grupo</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php
foreach($data as $dat) {
?>
<tr>
<td><?php echo $dat['id'] ?></td>
<td><?php echo $dat['nombre'] ?></td>
<td><?php echo $dat['email'] ?></td>
<td><?php echo $dat['telefono'] ?></td>
<td><?php
$datetime1 = date_create(date('Y-m-d')); <== FECHA ACTUAL
$datetime2 = date_create($dat['vence']); <== FECHA DE VENCIMIENTO GUARDADA EN LA BD
$dias= $diff = $datetime1->diff($datetime2); <== LO COMPARA
$dias = $datetime1->diff($datetime2)->format('%r%a'); <== SACA LAS CONCLUSIONES
// Si la fecha final es igual a la fecha actual o anterior <== MUESTRA MENSAJE SEGUN PROGRAMACION
if ($dias <= 0) {
echo '<span class="badge badge-danger">Vencido</span> ';
} elseif ($dias <= 3) {
echo '<span class="badge badge-warning">Está a ' . $dias . ' días de vencer</span>';
} else {
echo '<span class="badge badge-success">Activo</span>';
}
?></td>
<td><?php echo $dat['tipago'] ?></td>
<td><?php echo $dat['grupo'] ?></td>
<td></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>