September 19, 2009

date = date + 30 days in mysql

Add 30days to the current date and update in mysql. Try this code in PHP to get the future date (30 days interval),

<?php

$current_date = date("d-m-Y");
list($day, $month, $year) = split("-", $current_date);
$timeStamp = mktime(0,0,0,$month,$day,$year);
$timeStamp = $timeStamp + (30 * 24 * 60 * 60); #Add 30 days, in seconds
$future_date = date("d-m-Y", $timeStamp); #output the result

echo $future_date;

?>

1 comment: