ItSolutionStuff.com

PHP Subtract Year from Date Example

By Hardik Savani • May 14, 2024
PHP

In this article we will cover on how to implement how to subtract year to date in php. This article goes in detailed on how to sub year to current date in php. step by step explain how to sub 5 years to date in php. you can understand a concept of how to sub 10 years to date in php.

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

Example 1: PHP Subtract Year to Date

index.php

<?php

$date = "2021-11-01";

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

echo $newDate;

?>

Output:

2018-11-01

Example 2: PHP Subtract Year to Current Date

index.php

<?php

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

echo $newDate;

?>

Output:

2018-11-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 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 →

How to Add Days to Date in PHP?

Read Now →

How to Get Minimum Key Value of 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 →