PHP Add One Month, one day or one Year to todays date

Home » Blog » PHP Add One Month, one day or one Year to todays date

This example shows you how to add one day, one month or one year to todays date using PHP Date Functions.
for more information refer PHP.net

<?php

//PHP Example code to add one day,one month or one year to todays date

$todayDate = date("Y-m-d");// current date
echo "Today: ".$todayDate."<br>";

//Add one day to today
$dateOneDayAdded = strtotime(date("Y-m-d", strtotime($todayDate)) . "+1 day");

echo "After adding one Day: ".date('l dS \o\f F Y', $dateOneDayAdded)."<br>";

//Add one month to today
$dateOneMonthAdded = strtotime(date("Y-m-d", strtotime($todayDate)) . "+1 month");

echo "After adding one month: ".date('l dS \o\f F Y', $dateOneMonthAdded)."<br>";

//Add one Year to today
$dateOneYearAdded = strtotime(date("Y-m-d", strtotime($todayDate)) . "+1 year");

echo "After adding one Year: ".date('l dS \o\f F Y', $dateOneYearAdded)."<br>";
?>

2 Comments on "PHP Add One Month, one day or one Year to todays date"

  1. Ashley says:

    Came in very handy,

    Thanks

    Reply →

Got something to say? Go for it!

CommentLuv badge

Pro Social Toolbar http://t.co/aFplIi36 via @daddydesign - 1 week ago

 
Pro Social Toolbar http://t.co/aFplIi36 via @daddydesign1 week ago