yesterday date in php – How to Get Yesterday Date in PHP?

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

yesterday date in php

Get Yesterday to $Date can be done in many ways. The following source code will get yesterday’s date in php.

Also Read This ๐Ÿ‘‰   jQuery AJAX Dynamic Treeview Menu using PHP, MySQL

Example 1: yesterday date in php

how_to_get_yesterday_date_in_php.php

<?php
  
    $latestDt = date('Y-m-d', strtotime('-1 days'));
  
    echo $latestDt;
  
?>

Result

2022-11-12

don’t miss : Subtract Hours From DateTime In PHP

Example 2: how to get yesterday’s date in php

how_to_get_yesterday_date_in_php.php

<?php
  
    $latestDt = date('Y-m-d', strtotime('yesterday'));
  
    echo $latestDt;
  
?>

Result

2022-11-12

I hope you get an idea about yesterday’s 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.