3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //Enter your code here, enjoy! $pay_date = '20140808'; $cutoff_date = '20140728'; $next_bill_date = '20140808'; $recurrence = '3'; $rec = '3'; $today = date_create(); $cutoff_date = date_create_from_format('Ymd',$cutoff_date); $next_bill_date = date_create_from_format('Ymd',$next_bill_date); $pay_date = $next_bill_date; $outputstring = $pay_date->format('Ymd'); echo $outputstring; $days = ((int)date_format($pay_date, 'j'))-1; if ( $days > 0 ) { date_modify($pay_date, "-$days day"); } if($rec > 0){ $history = array ( 'account_id' => 'account', 'pay_amount' => '20.00', 'charity_id' => 'charity' ); if ($today > $cutoff_date) { date_modify($pay_date, '+1 month'); } for( $i = 1; $i <= $rec; ++$i ) { $history['pay_month'] = date_format($pay_date,'n'); $history['pay_year'] = date_format($pay_date,'Y'); print_r($history); if ( $i == $rec ) break; date_modify($pay_date, '+1 month'); } } else { $newData = array( 'charity_id' => $data['charity_id'], 'account_id' => $data['account'], 'action' => 'Unselected Charity : charity' ); print_r($newData); }
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.30, 7.1.0alpha1 - 7.1.0RC5
20140808Array ( [account_id] => account [pay_amount] => 20.00 [charity_id] => charity [pay_month] => 8 [pay_year] => 2014 ) Array ( [account_id] => account [pay_amount] => 20.00 [charity_id] => charity [pay_month] => 9 [pay_year] => 2014 ) Array ( [account_id] => account [pay_amount] => 20.00 [charity_id] => charity [pay_month] => 10 [pay_year] => 2014 )
Output for 5.3.29, 5.4.31 - 5.6.21, hhvm-3.12.0, 7.0.0 - 7.0.6
20140808Array ( [account_id] => account [pay_amount] => 20.00 [charity_id] => charity [pay_month] => 9 [pay_year] => 2014 ) Array ( [account_id] => account [pay_amount] => 20.00 [charity_id] => charity [pay_month] => 10 [pay_year] => 2014 ) Array ( [account_id] => account [pay_amount] => 20.00 [charity_id] => charity [pay_month] => 11 [pay_year] => 2014 )
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined function date_create_from_format() in /in/rRDDb on line 12
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function date_create() in /in/rRDDb on line 11
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_create() in /in/rRDDb on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: date_create() in /in/rRDDb on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_create() in /in/rRDDb on line 11