@ 2017-06-27T13:42:50Z <?php
$facturation = [
'start_time' => '27/06/2017',
'mtt' => '50000',
'periodicite' => '12'
];
var_dump(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.20 , 7.2.6 - 7.2.33 , 7.3.16 - 7.3.31 , 7.4.0 - 7.4.25 , 7.4.27 - 7.4.33 , 8.0.0 - 8.0.12 , 8.0.14 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 int(1498514400)
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
int(1498514400)
Output for 7.3.32 - 7.3.33 , 7.4.26 , 8.0.13 int(1498521600)
preferences:dark mode live preview
159.27 ms | 401 KiB | 171 Q