sc_date_dif_2 Macro

Hi, this macro have problems.

I want to work with 30 days months and I used the sc_date_dif_2 macro and works well some months ago. but not now.

Try this code in a blank app:
$diasc2 = array();
$diasc2 = sc_date_dif_2(‘2017-01-01’, “yyyy-mm-dd”, ‘2017-12-30’, “yyyy-mm-dd”,2);
$diasce = $diasc2[0];
$mesesc = $diasc2[1];
$anosc = $diasc2[2];
$diasc2 = (($anosc * 360) + ($mesesc * 30) + $diasce);
echo($diasc2);

I expected to get 1 year 0 months 0 days and the result is 11 months and 29 days
Echo-> 359

If you change the number 2 at the end of the macro, the result is the same.

Please help me to check this code.

Regards,

Guido Angulo

Hello,

The values are correct, you can certify in the online calculator below.

https://calcuworld.com/calendar-calculators/time-between-dates-calculator/

OBS: It would only give 1 year if the value is: 2018-01-01

Ex:

$diasc2 = sc_date_dif_2 (‘2017-01-01’, ‘yyyy-mm-dd’, ‘2018-01-01’, ‘yyyy-mm-dd’, 1);

$diasce = $diasc2[0];
$mesesc = $diasc2[1];
$anosc = $diasc2[2];

echo "Dias: " . $diasce;
echo “<br>”;
echo "Mes: " . $mesesc;
echo “<br>”;
echo "Ano: " . $anosc;
echo “<br>”;

Thanks for yor reply Yuri.

I used this macro some years ago and worked fine for me when add the first day, but now there is no difference changing the last number of the macro 1/2.

I created a new function to replace this macro with php DIFF.

best regards,