get max date from array and add days to current date
<?php
$dateRanges = array(
array('from' => '2023-04-01 03:00 PM', 'to' => '2023-04-05 03:00 PM'),
array('from' => '2023-04-10 03:00 PM', 'to' => '2023-04-15 03:00 PM'),
array('from' => '2023-04-20 03:00 PM', 'to' => '2024-04-22 03:00 PM')
// Add more date ranges as needed
);
$maxDate = null;
foreach ($dateRanges as $range) {
$toDate = strtotime($range['to']);
if ($maxDate === null || $toDate > $maxDate) {
$maxDate = $toDate;
}
}
$maxDateFormatted = date('Y-m-d H:i A', $maxDate);
echo "Maximum Date: " . $maxDateFormatted . "<br>";
$currentDate = time();
$diff = date_diff(date_create(date('Y-m-d', $currentDate)), date_create(date('Y-m-d', $maxDate)));
$daysUntilMaxDate = $diff->days;
echo "Days until maximum date: " . $daysUntilMaxDate;
?>
Comments
Post a Comment