In this blog, We will understand how to add days to date in PHP. This is used many times in projects from small-scale to large-scale projects.
There are many developers who remember this method because it's repeated in every project.
So, I will show you how to do this with examples.
Lets get started with this,
Add Days to Date PHP
<?php
$date = "2023-06-02";
$newDate = date('Y-m-d', strtotime($date. ' + 4 days'));
echo $newDate;
?>
Output:
2023-06-06
Add Date to Current Date PHP
<?php
$newDate = date('Y-m-d', strtotime( ' + 4 days'));
echo $newDate;
?>
Output:
2023-06-06
I hope you understood this. If you have any doubts please let me know in comments.
0 Comments