php

How to add days to a date in PHP

In this tutorial, we are going to see how to add days to a date in PHP. Adding days to a Date can be done in different ways. It is very easy to do using built-in functions like strtotime(), date() in PHP.
 

How to add days to a date in PHP

The following source code will add 5 days to a given date.

<?php
    $date = "2020-01-15";
    echo date('Y-m-d', strtotime($date. ' + 5 days'));
?>

Output:

2020-01-20
 

How to add days to the current date in PHP

The following source code will add 5 days to the current date.

<?php echo date('Y-m-d', strtotime(' + 5 days')); ?>
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *