ItSolutionStuff.com

How to Add Year to Date in PHP?

By Hardik Savani • May 14, 2024
PHP

Here, i will show you how to add year to date in php. i explained simply about how to add 5 years to current date in php. we will help you to give example of php add year to date. we will help you to give example of php add 1 year to current date.

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

Example 1: PHP Add Year to Date

index.php

<?php

$date = "2022-02-01";

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

echo $newDate;

?>

Output:

2027-02-01

Example 2: PHP Add Year to Current Date

index.php

<?php

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

echo $newDate;

?>

Output:

2026-03-01

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

Read Now →

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

Read Now →

How to Find Number from String in PHP?

Read Now →

How to Get HTML Tag Value in PHP?

Read Now →

PHP Explode Every Character into Array Example

Read Now →

PHP Copy File from One Folder to Another Example

Read Now →

PHP Remove Directory and Files in Directory Example

Read Now →

How to Check If a String Contains HTML Tags in PHP?

Read Now →

How to Remove Null Values from Array in PHP?

Read Now →

How to Merge Two Array with Same Keys without Loop in PHP?

Read Now →