I use the below logic in PHP to generate the following billing date based on the pricing for my subscription:
$today = date('d');
$checkDate = '15';
if ($today >= $checkDate) {
$nextPaymentDate = date('Y-m-01', strtotime('+2 month'));
} else {
$nextPaymentDate = date('Y-m-01', strtotime('next month'));
}
Basically, when a customer purchases a subscription before date 15, the next payment date should be set to the first date of the next month. In addition, it should be set on the first date of the next month.
This logic worked until yesterday (until December 28, 2014) . As expected until December 15, I received 2015-01-01. And after December 15th I received 2015-02-01. But from today, I get nextPaymentDate as 2015-03-01.
I also tried
if ($today >= $checkDate) {
$nextPaymentDate = date('Y-m-01', strtotime('next month'));
$nextPaymentDate = date($nextPaymentDate, strtotime('next month'));
But it gives the same result: (
, , 29 30 31 . , 31- .
? , .