ItSolutionStuff.com

How to Get Yesterday Date in PHP?

By Hardik Savani • May 14, 2024
PHP

In this post, we will learn how to get yesterday date in php. if you have question about how to get previous date in php then i will give simple example with solution. you will learn how to get previous day date in php. you can see php get yesterday date. Let's see bellow example php get previous date.

I will give you very simple example how to yesterday date in PHP. so let's see both example with output:

Example 1:

index.php

<?php

$newDate = date('Y-m-d', strtotime('-1 days'));

echo $newDate;

?>

Output:

2021-11-12

Example 2:

index.php

<?php

$newDate = date('Y-m-d', strtotime('yesterday'));

echo $newDate;

?>

Output:

2021-11-12

i hope it can help you...

Tags: PHP
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Subtract Minutes from DateTime in PHP?

Read Now →

How to Subtract Hours from DateTime in PHP?

Read Now →

How to Add Seconds to Time in PHP?

Read Now →

PHP Add Minutes to Time Example

Read Now →

PHP Add Hours to Datetime Example

Read Now →

PHP Subtract Year from Date Example

Read Now →

PHP Subtract Month from Date Example

Read Now →

How to Subtract Days to Date in PHP?

Read Now →

How to Add Year to Date in PHP?

Read Now →

How to Add Months to Date in PHP?

Read Now →