Can someone out there help me with this:
<?php
include 'include/db_config.php';
$result = $dbs->prepare("SELECT * FROM service_info WHERE id = :id");
$result->bindParam(':id', $_SESSION['id']);
$result->execute();
for ($i=0;$i = 0; $row = $result->fetch(); $i++) {
?>
<td><?php echo $row['datepicker']; ?></td>
<?php
$offset = strtotime("+1 day");
$enddate = date("Y-m-d H:i:s", $offset);
echo $enddate . "</br>";
if ($enddate < $startdate) {
echo "expired";
} else {
echo "active";
}
}
?>
What I want to achieve is to find out if the date value held in $row['datepicker']
was more than 2 days ago. If it was more than 2 days ago I want it to echo expired
and otherwise I want it to show active
.
For example:
$row['datepicker']
could contain the date: May 18, 2016 (based on the users input - not a fixed value). That would mean it's expiration date would be: May 20,2016. If today's date is greater than or equal to May 20th 2016, it should echo expired
. If today's date was May 19th 2016 it should echo active
because it is not yet two days in the past.
if($offset < strtotime($startdate)) { ...
– Richard May 18 '16 at 14:02