generate functionSun, 27 Nov 2022

php check if given date time has passed or is tomorrow or is today or in the future

public function date_time_check($date) { $given = new DateTime($date); $today = new DateTime('today'); $tomorrow = new DateTime('tomorrow'); if ($given < $today) { return "Expired"; } if ($given >= $today && $given < $tomorrow) { return "Today"; } if ($given >= $tomorrow) { return "Future"; } }

Questions about programming?Chat with your personal AI assistant