I've started using PHP Carbon for my application since it seems so much easier than using and manipulating date/time with the DateTime class. What I want to do is check if the chosen date ($chosen_date) is greater than another date ($whitelist_date). I have tried this in the code below:
$chosen_date = new Carbon($chosen_date);
$whitelist_date = Carbon::now('Europe/London');
$whitelist_date->addMinutes(10);
echo "Chosen date must be after this date: ".$whitelist_date ."</br>";
echo "Chosen Date: ".$chosen_date ."</br>";
if ($chosen_date->gt($whitelist_date)) {
echo "proceed";
} else {
echo "dont proceed";
}
The original $chosen_date value comes from POST data. Here is the output I get:
Chosen date must be after this date: 2015-09-22 21:21:57
Chosen Date: 2015-09-22 21:01:00
proceed
Clearly the chosen date is not greater than the whitelist date but still the if statement returns true and echo's "proceed". I have been over the code over and over but I can't see where I have gone wrong.
09/22/2015 9:36 PM
- in this format. – Buckthorn