Wednesday, April 29, 2009

Adding days to a date in PHP

Here is the small and most useful function to add days to a particular date.

function dayadd($g,$dayYmd) {
//add $g days to $dayYmd (date is in YYYY-MM-DD format)
$d = strtotime($dayYmd);
$cc = 24*60*60*$g + 60*60 + $d;
return date("Y-m-d",$cc);
}
?>

Labels: , ,

posted by adityachandra @ 12:29 PM,


0 Comments:

Post a Comment