How to check if date is future date in php?
This tutorial shows you how to check date is future date in php. you will learn php check if date is after today.
1. Code:
<?php function checkIfDateIsFutureDate($date){ $startDate = strtotime(date('Y-m-d', strtotime($date) ) ); $currentDate = strtotime(date('Y-m-d')); if($startDate > $currentDate) { return true; } return false; } var_dump(checkIfDateIsFutureDate('2022-11-30')); echo "<br>"; var_dump(checkIfDateIsFutureDate('2021-11-30')); ?>
2. Example:
Input:
date 1: 2022-11-30 date 2: 2021-11-30
Output:
output: true output: false