symfony - iterate and print all date in range in twig -


i trying iterate dates in twig

i have tried using this:

{% x in range(startdate|date('u'), enddate|date('u'), 86400 ) %}   {{ x|date('m/d') }} {% endfor %}  

it worked in dates. if startdate 10/01/2015 , enddate 10/31/2015 10/25 displayed twice.

the scenario can replicated on octobers of year on 4th sundays

i don't know if it's me can replicate this.

is there other way iterate dates in range in twig?

the \dateperiod class created purpose, , it's available since php5.3.

$start = datetime::createfromformat("y-m-d", "2015-10-01"); $end = datetime::createfromformat("y-m-d", "2015-11-01"); $interval = new dateinterval("p1d");  $range = new dateperiod($start, $interval, $end);  foreach ($range $date) {     var_dump($date->format("y-m-d")); } 

you can try at: https://3v4l.org/vfsb6


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -