ItSolutionStuff.com

How to Subtract Days to Date in PHP?

By Hardik Savani • May 14, 2024
PHP

In this example, you will learn how to subtract days to date in php. This post will give you simple example of how to sub days to current date in php. we will help you to give example of how to sub 7 days to date in php. This article will give you simple example of how to sub 30 days to date in php. Follow bellow tutorial step of subtract one day to date in php.

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

Example 1: PHP Subtract Days to Date

index.php

<?php

$date = "2021-11-01";

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

echo $newDate;

?>

Output:

2021-10-29

Example 2: PHP Subtract Days to Current Date

index.php

<?php

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

echo $newDate;

?>

Output:

2021-11-06

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 Add Months to Date in PHP?

Read Now →

How to Add Days to Date in PHP?

Read Now →

PHP - How to Get File Name and Extension form URL?

Read Now →

How to Get HTML Tag Value in PHP?

Read Now →

PHP Array Get Previous Element from Current Key

Read Now →

How to Remove White Space from String in PHP?

Read Now →

How to Convert Object into Array in PHP?

Read Now →

How to Find Day Name from Specific Date in PHP?

Read Now →

How to Remove Null Values from Array in PHP?

Read Now →