How to Subtract Days to Date in PHP?

By Hardik Savani May 14, 2024 Category : 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 :
Shares