I have a couple of date times :
DateTime {#2205 ▼ +"date": "1970-01-01 12:30:00.000000" +"timezone_type": 3 +"timezone": "UTC" } DateTime {#2206 ▼ +"date": "1970-01-01 20:00:00.000000" +"timezone_type": 3 +"timezone": "UTC" } I just demand to determine the current time is between first and second times. Here is my code:
private function dateIsBetween($from, $to,$currentdate) { if ($currentdate >= $from && $currentdate <= $to) { return true; } return false; } public function checkTimes($foodTime) { $currentTime = new \DateTime(); var_dump($foodTime->getTimeStartNoon(),$foodTime->getTimeEndNoon()); return $this->dateIsBetween($foodTime->getTimeStartNoon(),$foodTime->getTimeEndNoon(),$currentTime); } The essential issue I should fix is changing date's year to current year. is it possible with Carbon (or pure PHP) and how?