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");

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Thanks guys for your quick response but something seems to be wrong. Here is the code on the page

 

$date_created = $_POST['date_created'];

$date_due = date('Y-m-d', strtottime('+30 days $date_created'));

 

Doesn't work? Any suggestions?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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