We use cookies to ensure you get the best experience on our website.
<?php
function isDateInRange($tmpDate, $startDate, $endDate) {
// Convert dates to DateTime objects for easier comparison
$date = new DateTime($tmpDate);
$startDate = new DateTime($startDate);
$endDate = new DateTime($endDate);
// Check if the date is within the range
return ($date >= $startDate && $date <= $endDate);
}
// Example usage
$tmpDate = '2024-07-10';
$startDate = new DateTime((new DateTime($tmpDate))->format('Y-m-01'));
$endDate = '2024-07-15';
if (isDateInRange($tmpDate, $startDate->format('Y-m-d'), $endDate)) {
echo "The date $tmpDate is within the range from " . $startDate->format('Y-m-d') . " to $endDate.";
} else {
echo "The date $tmpDate is not within the range from " . $startDate->format('Y-m-d') . " to $endDate.";
}
?>
Cześć Podróżniku!
Ta strona ma nie być typowym poradnikiem w IT, Głównym jej cel to zapisanie krótkich notatek, które mogą się przydać w codziennym życiu podczas korzystania/konfiguracji różnych urządzeń np. Ustawienia DHCP na Routerze Cisco, Ustawieniu Karty sieciowej na Linuxie itp.
Wszelkie prawa zastrzeżone
Dodaj komentarz