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. i explained simply about php check if date after today. We will look at example of php check if date greater than today. Alright, let’s dive into the steps.
I will give you very simple example how to check if date is future date or not in PHP. so let's see both example with output:
Example 1: PHP Check Date is Future Date from Current Date
index.php
<?php
$startDate = strtotime(date('Y-m-d', strtotime('2021-11-30') ) );
$currentDate = strtotime(date('Y-m-d'));
if($startDate > $currentDate) {
echo 'date is a future';
}
?>
Output:
date is a future
Example 2: PHP Check Date is Future Date from Date
index.php
<?php
$startDate = strtotime(date('Y-m-d', strtotime('2021-11-30') ) );
$currentDate = strtotime('2021-11-20');
if($startDate > $currentDate) {
echo 'date is a future';
}
?>
Output:
date is a future
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Get Month Name from Date in PHP?
- How to Get Full Day Name from Date in PHP?
- How to Get Previous Month from Date in PHP?
- How to Get Next Month Date in PHP?
- How to Get Tomorrow Date in PHP?
- How to Get Yesterday Date in PHP?
- PHP Subtract Seconds from Time Example
- How to Subtract Minutes from DateTime in PHP?
- How to Subtract Hours from DateTime in PHP?
- How to Add Seconds to Time in PHP?