How to Check If Date is Past Date in PHP?

By Hardik Savani November 5, 2023 Category : PHP

In this example, i will show you how to check date is past date in php. step by step explain php check if date is before today. you can see php check if date before today. we will help you to give example of php check if date less than today.

I will give you very simple example how to check if date is past date or not in PHP. so let's see both example with output:

Example 1: PHP Check Date is Past Date from Current Date

index.php

<?php

$startDate = strtotime(date('Y-m-d', strtotime('2021-11-15') ) );

$currentDate = strtotime(date('Y-m-d'));

if($startDate < $currentDate) {

echo 'date is in the past';

}

?>

Output:

date is in the past

Example 2: PHP Check Date is Past Date from Date

index.php

<?php

$startDate = strtotime(date('Y-m-d', strtotime('2021-11-15') ) );

$currentDate = strtotime('2021-11-20');

if($startDate < $currentDate) {

echo 'date is in the past';

}

?>

Output:

date is in the past

i hope it can help you...

Tags :
Shares