Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
<?php
$checkDate1 = new DateTime("2020-06-25");
$checkDate2 = new DateTime("2020-01-30");
$startDate = new DateTime("2020-06-20 00:00:00");
$endDate = new DateTime("2020-06-30 23:59:59");
//bool(true)
var_dump(
isDateBetweenDates($checkDate1, $startDate, $endDate)
);
//bool(false)
var_dump(
isDateBetweenDates($checkDate2, $startDate, $endDate)
);
function isDateBetweenDates(DateTime $date, DateTime $startDate, DateTime $endDate) {
return $date > $startDate && $date < $endDate;
}
If the date is in normal format, then just like any other value.
You can practice on cats first.
3 is in the range from 2 to 5? and 7?
after you write the code for these checks, it will be the same for dates.
$date = '17.03.2020';
$timestamp = strtotime($date);
$from = strtotime('19.03.2020');
$to = strtotime('23.05.2020');
if ($timestamp > $from && $timestamp < $to) {
return true;
} else {
return false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question