JU5TY Posted November 9, 2010 Share Posted November 9, 2010 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 More sharing options...
requinix Posted November 9, 2010 Share Posted November 9, 2010 Aren't you storing the purchase date somewhere? Like in a database? When the due date passes and a new one is created, update it. Link to comment https://forums.phpfreaks.com/topic/218223-php-dates/#findComment-1132347 Share on other sites More sharing options...
litebearer Posted November 9, 2010 Share Posted November 9, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.