Hello Henry, I just check your timestamp and I get : 1395961200 = 27/03/2014 23:00:00 And 1396216800 = 30/03/2014 22:00:00
So result is quite good (3 days and 23h) may be you should strip hour from your timestamp if you wish only "day" difference. Cedric -----Message d'origine----- De : dolibarr-dev-bounces+c.gross=kreiz-it...@nongnu.org [mailto:dolibarr-dev-bounces+c.gross=kreiz-it...@nongnu.org] De la part de Florian Henry Envoyé : mercredi 5 mars 2014 12:22 À : ML Dolibarr Dev Objet : [Dolibarr-dev] Question and bug about num_between_day in date.lib.php Hi all, I've got a problem into Holiday module, but also can give some strange result to other part of code that use function num_between_day of date.lib.php My case : Find number of day betwenn 21-March-2014 and 24-March-2014 Result is 4 => OK (Friday,Saturday,Sunday,Monday) Find number of day betwenn 28-March-2014 and 31-March-2014 Result is 3 => KO. (Friday,Saturday,Sunday,Monday) If I look into code of this function we have a basic timestamp substraction, that should give a good result, but in fact not. Is it the only case ? I don't know. I put some trace and there is the result : 21-24 : $timestampStart=1395356400 $timestampEnd =1395615600 $bit=0 ($timestampEnd - $timestampStart)/(60*60*24) +1 - $bits = 4 floor(4) = 4 28-31 : $timestampStart=1395961200 $timestampEnd =1396216800 $bit=0 ($timestampEnd - $timestampStart)/(60*60*24) + 1 - $bits = 3.9583333333333 floor(3.9583333333333) = 3 As we do a floor on this ($timestampEnd - $timestampStart)/(60*60*24) the second result is KO If I use the DateTime php object method the result is correct. But this core php object exists only for php version 5.3 and more. So more than the minimum version 5.2.1 describe into the wiki. As patch for now I use round instead of floor but all php code line I can found on internet use floor for this type of calculation, so what is the good option ? I've create a bug into DoliForge : https://doliforge.org/tracker/?func=detail&aid=1287&atid=246&group_id=144 but still do not have a clue about why the strong calculation rule do not work in this specifics case. Regards -- Florian HENRY florian.he...@open-concept.pro +33 6 03 76 48 07 http://www.open-concept.pro Twitter : @_Open_Concept_ _______________________________________________ Dolibarr-dev mailing list Dolibarr-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/dolibarr-dev _______________________________________________ Dolibarr-dev mailing list Dolibarr-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/dolibarr-dev