ItSolutionStuff.com

How to Add Days to Date in PHP?

By Hardik Savani β€’ May 14, 2024
PHP

This article goes into detail on how to add days to date in PHP. step by step explain how to add days to the current date in PHP. it's a simple example of how to add 7 days to date in PHP. This article goes into detail on how to add 30 days to date in PHP. Alright, let’s dive into the steps.

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

Example 1: PHP Add Days to Date

index.php

<?php

$date = "2021-11-01";

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

echo $newDate;

?>

Output:

2021-11-04

Example 2: PHP Add 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: 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 Extract All Email Addresses from String in PHP?

Read Now β†’
β˜…

How to get HTML Tag Attribute Value in PHP?

Read Now β†’
β˜…

Moment JS Get Year from Date Example

Read Now β†’
β˜…

JQuery Moment Get Current Date Example

Read Now β†’
β˜…

Laravel Carbon Check Date is in Past Date Code

Read Now β†’
β˜…

How to Change Date Format in PHP?

Read Now β†’
β˜…

PHP MySQL Column Sorting Example Tutorial

Read Now β†’
β˜…

PHP Check Word Exist in String or Not Example

Read Now β†’
β˜…

How to Find Day Name from Specific Date in PHP?

Read Now β†’