Hi I'd like some help comparing dates. This is my code
date_default_timezone_set('Europe/London');
// get today's date
$datetoday = date('Y-m-d');
if ($datetoday > $pickup_date) {
array_push($errors, "this pickup date is invalid, it has already passed");
The pickup date is a value I collect from a form, here is the code for the form:
<div class="input-group">
<label>Pickup Date</label>
<input type="date" name="pickup_date" >
</div>
what I want is for the user to not be able to set the pickup date to a date which has already gone. My system is a booking system. They should be only able to set dates which are after today's date.
But this current code does not work, it still allows the user to book dates before and after today's date. I've even tried switching the comparison operators around where it compares the dates.
Thanks all help is appreciated.