SL8R.co.uk - Code Zone

Code, Code and Code

SL8R.co.uk - Code Zone header image 4

PHP: Add a number of days to a date

April 11th, 2008 · 1 Comment

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;

addthis_url = ‘http%3A%2F%2Fwww.sl8r.co.uk%2F2008%2F04%2F11%2Fphp-add-a-number-of-days-to-a-date%2F’;
addthis_title = ‘PHP%3A+Add+a+number+of+days+to+a+date’;
addthis_pub [...]

[Read more →]

Tags: Code