...

View Full Version : Add days to date function



codebyte
06-27-2010, 11:12 AM
hi

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...

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

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

codebyte
06-27-2010, 11:32 AM
hi...

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....

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


<?php
$date = date("D\m\Y");
$date = $date + 3456000;
echo $date
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum