View Full Version : Add days to date function

06-27-2010, 10:12 AM

i have a problem with my program that needs to add days to a certain date
For example..if i need to add 40 days to a given date..how do i do it? the following code doesn't work for me...

// current date
$date = date("Y-m-d");

$date = strtotime(date("Y-m-d", strtotime($date)) . " + 40 days");
echo "Date is: $date";

it just prints...Date is: 1277683200 on the screen. thanks in advance...

06-27-2010, 10:15 AM
40 days are 3456000 seconds, just + that.

06-27-2010, 10:23 AM
how exactly should i do it? i can't get it to work even if i add the seconds..

06-27-2010, 10:32 AM

i just found an answer to my previos question

the following code adds 40days to a given date...

echo "Date +40days is".date('Y-m-d', strtotime("+40 days"));

thanks to those who replied to my question....

06-27-2010, 10:50 AM
Sorry, I was really in a hurry when writing to this topic. Here's a way.

$date = date("D\m\Y");
$date = $date + 3456000;
echo $date