I am trying to compare a date with a date in a MySQL database that is either greater than 90, 60, 30 days from the current date. I'm using the DateTime object and it's been easy to manipulate but I'm having issues getting the response I'm looking for. Any help is much appreciated.
<?php
//date_default_timezone_set('America/Chicago');
$todaysDate = new DateTime('now');
$formattedDate = $todaysDate->format('Y-m-d');
$date = new DateTime ('now');
$date90 = $date->add(new DateInterval('P90D'));
$date90 = $date->format('Y-m-d');
$date = new DateTime ('now');
$date60 = $date->add(new DateInterval('P60D'));
$date60 = $date->format('Y-m-d');
$date = new DateTime ('now');
$date30 = $date->add(new DateInterval('P30D'));
$date30 = $date->format('Y-m-d');
//echo $date90;
//echo "<br />";
//echo $formattedDate;
$thirtyDays = array();
$sixtyDays = array();
$ninetyDays = array();
$sql = "SELECT * FROM service;";
if(!$result = $con->query($sql)){
die('There was an error running the query [' . $con->error . ']');
}else{
//$numRows = $result->num_rows;
while($row = $result->fetch_array()){
$boosterDate = $row['boosterDate'];
}
}
if($boosterDate > $date90){
echo "greater than 90 days";
echo "<br />";
}
?>