get previous date from given date in php – How to Check If Date is Past Date in PHP?

get previous date from given date in php and display it. The PHP date function is used to format a date. here we can learn to main 2 Examples.

get previous date from given date in php

Get & Check previous date to $current_date can be done in many ways. The following source code will get previous date from given date in php.

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

php_check_date_is_past_date_from_current_date.php

<?php
  
    $joinDt = strtotime(date('Y-m-d', strtotime('2022-11-15') ) );
    $activeDt = strtotime(date('Y-m-d'));
   
    if($joinDt < $activeDt) {
        echo 'date is in the past';
    }
  
?>

Result

date is in the past

don’t miss : How To Get Month From Date In Php?

Also Read This πŸ‘‰   download csv file in php example

Example 2: PHP Check Date is Past Date from Date

php_check_date_is_past_date_from_date.php

<?php
  
    $joinDt = strtotime(date('Y-m-d', strtotime('2022-11-15') ) );
    $activeDt = strtotime('2022-11-20');
   
    if($joinDt < $activeDt) {
        echo 'date is in the past';
    }
  
?>

Result

date is in the past

I hope you get an idea about get previous date from given date in php.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.