ItSolutionStuff.com

PHP Subtract Month from Date Example

By Hardik Savani β€’ May 14, 2024
PHP

In this tutorial, you will learn how to subtract month to date in php. if you have question about how to sub month to current date in php then i will give simple example with solution. let’s discuss about how to sub 1 month to date in php. i explained simply about how to sub month to date in php.

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

Example 1: PHP Subtract Month to Date

index.php

<?php

$date = "2021-11-01";

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

echo $newDate;

?>

Output:

2021-08-01

Example 2: PHP Subtract Month to Current Date

index.php

<?php

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

echo $newDate;

?>

Output:

2021-08-10

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

Read Now β†’
β˜…

How to Add Months to Date in PHP?

Read Now β†’
β˜…

How to Add Days to Date in PHP?

Read Now β†’
β˜…

How to Find Number from String in PHP?

Read Now β†’
β˜…

How to Connect SSH using PHP?

Read Now β†’
β˜…

How to Remove Multiple Keys from PHP Array?

Read Now β†’
β˜…

How to access PHP variables in JQuery?

Read Now β†’
β˜…

How to Find Day Name from Specific Date in PHP?

Read Now β†’