@ 2017-06-27T13:43:56Z <?php
$facturation = [
'start_time' => '27/06/2017',
'mtt' => '50000',
'periodicite' => '12'
];
var_dump(date('Y-m-d H:i:s', strtotime(str_replace('/', '-', $facturation['start_time']))));
die;
// generate tasks depending on amount (/x days + rest in last
// start_time and end_time accordingly
$tasks_data = [];
$current_start_time = date('Y-m-d', strtotime(str_replace('/', '-', $facturation['start_time'])));
// calculate mtt per month approximately
$mtt_per_period = floatval($facturation['mtt']) / floatval($facturation['periodicite']);
$mtt_per_period = number_format((float)$mtt_per_period, 2, '.', '');
$delta_time = ($facturation['periodicite'] == '12') ? '1 month' : '1 year';
for ($i=0; $i < $facturation['periodicite'] ; $i++) {
$current_end_time = date('d/m/Y', strtotime($current_start_time . ' +' . $delta_time));
$budget = $mtt_per_period;
if ($i === intval($facturation['periodicite'])-1) {
$budget = floatval($facturation['mtt']) - ((floatval($facturation['periodicite'])-1) * $mtt_per_period);
$budget = number_format((float)$budget, 2, '.', '');
}
$tasks_data[] = [
'start_time' => $current_start_time,
'end_time' => $current_end_time,
'title' => ($facturation['periodicite'] == '12') ? 'acompte ' . '' . explode('/', $current_start_time)[2] : 'échéance unique',
'budget' => $budget
];
$current_start_time = date('d/m/Y', strtotime($current_start_time . ' +' . $delta_time));
}
var_dump($tasks_data);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 string(19) "2017-06-27 00:00:00"
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
string(19) "2017-06-27 00:00:00"
preferences:dark mode live preview
222.77 ms | 402 KiB | 203 Q