By Jason Slater
Friday, 11 April 2008
Friday, 11 April 2008
example code to add a number of days to a date
// add 5 days
$daystoadd=5;
// calculate hours
$hours=$daystoadd * 24;
// get today
$dd=date(d);
$mm=date(m);
$yy=date(y);
// calculate the new date
$newdate=date("d-m-y", mktime($hours, 0, 0, $mm, $dd, $yy));
// show the new date
echo "The new date is: " . $new;
Related
- PHP: Format and show an expiration date
- Shell Script: Random Number
- PHP: Get PHP Information
- Software Code Commenting
- PHP: Web Service Feed Information



[...] today dd=dated mm=datem yy=datey // calculate the new date newdate=date"d-m-y", mktimehours,http://www.sl8r.co.uk/2008/04/11/php-add-a-number-of-days-to-a-date/mktimeMKTIME.C: The example takes a number of days * as input and returns the time, the current * [...]