How to Subtract Days to Date in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Add Months to Date in PHP?
- How to Add Days to Date in PHP?
- PHP - How to Get File Name and Extension form URL?
- How to Get HTML Tag Value in PHP?
- PHP Array Get Previous Element from Current Key
- How to Remove White Space from String in PHP?
- How to Convert Object into Array in PHP?
- How to Find Day Name from Specific Date in PHP?
- How to Remove Null Values from Array in PHP?