php - DateTime period issues -


i've got strange behaviour datetime's in php. reason code produces wrong result:

$period = new dateperiod(             new datetime('2017-03-20'),             dateinterval::createfromdatestring('1 day'),             new datetime('2017-03-31')         ); foreach($period $dt){   $a[] = $dt->format('y-m-d'); } 

so expected result period 20 31, it's not. here actual result:

array (     [0] => 2017-03-20     [1] => 2017-03-21     [2] => 2017-03-22     [3] => 2017-03-23     [4] => 2017-03-24     [5] => 2017-03-25     [6] => 2017-03-26     [7] => 2017-03-27     [8] => 2017-03-28     [9] => 2017-03-29     [10] => 2017-03-30 ) 

so i'm missing here, or that's php bug?

following this user statement on official php documentation dateperiod::

[...] example include end date using datetime method 'modify'

this class seems ignore end date. need modify end date include gap (of +1 unit, in case +1 day).


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -