How to Check If Date is Future Date in PHP?

By Hardik Savani May 14, 2024 Category : 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...

Tags :
Shares