Alex Rivera | Logout

add day to current date

Asked 2010-10-12T20:18:41.677
21

add a day to date, so I can store tomorrow's date in a variable.

$tomorrow = date("Y-m-d")+86400;

I forgot.

Edit
Report

1 Answer

38

I'd encourage you to explore the PHP 5.3 DateTime class. It makes dates and times far easier to work with:

$tomorrow = new DateTime('tomorrow');

// e.g. echo 2010-10-13
echo $tomorrow->format('d-m-Y');

Furthermore, you can use the + 1 day syntax with any date:

$xmasDay = new DateTime('2010-12-24 + 1 day');
echo $xmasDay->format('Y-m-d'); // 2010-12-25
answered 2010-10-12T20:26:14.713

Your Answer