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