Jump to content

Due date plus x days


Ihsaan

Recommended Posts

like this.... 8)

 

 


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

$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");

 

Assuming $created_date is YYYY-MM-DD format

 

$due_date = date ('Y-m-d', strtottime("+30 days $created_date"));

 

If dates are Unix time values

 

$due_date = strtotime('+30 days' , $created_date);

 

Or if you are pulling created_date from a DB table

SELECT created_date + INTERVAL 30 DAY as due_date

Perhaps, you have an error somewhere in your script.

Copy/paste Barand's code and tell us what a result you get it.

$date_created = '2012-08-28';
$date_due = date('Y-m-d', strtotime("+30 days $date_created"));

echo $date_due ;         //--->  2012-09-27

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.