Hi,
I am using ARB Authorized.net subscription. my subscription start_date is 01 Jan,2010. I know that ARB will automatically bill my amount on date 01 of every month. But for some reason i need to get my next billing date. For example : I have to update my subscription today (14 May,2010) and I want to get my next billing date (which is 01 June,2010) from authorized.net. Can I get it from authorized.net or I have to get it manually from my site ?
Thanx
Subhash.
Solved! Go to Solution.
05-13-2010 11:20 PM - edited 05-13-2010 11:21 PM
Thank you so much. That make sense.
08-15-2011 09:06 AM
I realize that this is not a PHP forum, but I am looking for suggestions. I can calculate the last day of next month based on the current date so if today is 01/31 I can get 02/28, but I am not sure how to approach this if I am only storing the ARB start date. e.g. Start date = 01/31 and now it is 04/02 and I want to display the next bill date.
Any thoughts?
08-15-2011 02:40 PM
Depends. If you know it's 2011-04-02, then all you have to do is calculate how many days there are in the current month and then put that number in place of the 2, and to do that just requires knowing how many days each month has and how to calculate whether February has 28 or 29 days. Fairly simple. If you don't know it's 2011-04-02, you can use the date function to give you that information.
If your subscription started on the 27th, of course, you don't need to even bother with all of that - it's always going to be the 27th.
08-15-2011 05:05 PM
I think I have it for anyone else who is interested. Any thoughts and/or improvements are appreciated.
/** * Function to calculate the same day one month in the future. * * This is necessary because some months don't have 29, 30, or 31 days. * If thenext month doesn't have as many days as this month, the * anniversary will be moved up to the last day of the next month. * * @param $start_date * Function assumes that date is pulled from MySql YYYY-MM-DD * * @return $nextBillDate * Formmated in common US date format MM/DD/YYYY */ function getNextBillDate($start_date) { $date_array = explode("-",$start_date); // split the array $year = $date_array[0]; $month = $date_array[1]; $day = $date_array[2]; if (date("d") $day) { $billDay = $day; }else{ $billDay = $billMonthDays; } $nextBillDate = $billMonth . "/" . $billDay . "/" . date("Y"); return $nextBillDate; }
08-16-2011 07:16 AM - edited 08-16-2011 07:18 AM
Well, you're getting a bit closer, but there seem to be some errors and no explanation of where $billMonthDays is coming from.
08-16-2011 07:55 AM
Sorry about that, several lines keeping getting removed when I paste and I did not notice it before...
function getNextBillDate($start_date) { $date_array = explode("-",$start_date); // split the array $year = $date_array[0]; $month = $date_array[1]; $day = $date_array[2]; if (date("d") <= $day) { $billMonth = (int)date("m"); }else{ $billMonth = date("m")+1; } $billMonthDays = cal_days_in_month(CAL_GREGORIAN, ($billMonth), date("Y")); if ($billMonthDays > $day) { $billDay = $day; }else{ $billDay = $billMonthDays; } $nextBillDate = $billMonth . "/" . $billDay . "/" . date("Y"); return $nextBillDate; }
08-16-2011 08:05 AM
Someone brought an error to my attention. The following returns an error if we are in the month of December...
$billMonth = date("m")+1;
If you are using PHP 5.3+, you can use the following...
$billMonth = date_format(date_modify(date_create(), 'first day of next month'), 'm');
09-21-2011 09:08 AM