Jump to content

PHP Dates


JU5TY

Recommended Posts

Hi

 

I am storing my customer’s domain names in a database for billing purposes.

 

I have a domain purchase date, this then needs renewing every 2 years. I have a field which shows the purchase date and a field which shows the next renewal date.

 

I have written the below code:

 

$purchase_date = "2010-01-01";

 

if (strtotime($purchase_date) < time())  {

// Past date

$due_date = strtotime('+2 year' , strtotime ($purchase_date)) ;

$ due_date = date('d-m-Y' , $ due_date);

echo $due_date;

 

} else {

// Future Date

echo $purchase_date;

}

 

Which checks if the purchase date is in the past, if it is it adds two years onto the purchase date and displays this as the next due date. What I can’t work out is how to keep looping this, so its adding two years onto the NEW due date each time, rather than the old purchase date.

 

Any help much appreciated.

 

Link to comment
Share on other sites

random thoughts...

 

1. Purchase date will ALWAYS  be in the past.

 

2. Only use Purchase date + 2 yrs to calc the Next due upon creation of the record.

 

3. Check for records where Next Due <= Now. Get their $ or 'clip' their domain.

 

4. if you get their $, update Next Due for that record by adding 2 years to the existing Next Due

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.