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
https://forums.phpfreaks.com/topic/218223-php-dates/
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
https://forums.phpfreaks.com/topic/218223-php-dates/#findComment-1132348
Share on other sites

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.