Support

Account

Home Forums Add-ons Repeater Field repeater dates arranged by months title Reply To: repeater dates arranged by months title

  • Hi @felix007

    tr1_date1 is my date field name. I’m sorry I forgot to change it. Here is another way to achieve what you want:

    $repeater = get_field('repeater_field_name');
    $order = array();
    $now = strtotime("now");
    $sortedDate = array();
    
    foreach( $repeater as $i => $row ) {
        $order[ $i ] = $row['date_field_name'];
    }
    array_multisort( $order, SORT_ASC, $repeater );
    
    foreach($repeater as $row){
        $theDate = strtotime(str_replace('/', '-', $row['date_field_name']));
        if($theDate > $now){
            $theMonth = substr($row['date_field_name'],3 ,2);
            if (!isset($sortedDate[$theMonth])){
                $sortedDate[$theMonth] = array();
            }
            array_push($sortedDate[$theMonth], $row);
        }
    }
    
    foreach($sortedDate as $theMonth => $theDates){
        echo $theMonth;
        foreach($theDates as $theDate){
            echo $theDate['date_field_name'];
        }
    }

    If you don’t understand it, please hire a developer to help you out with it.

    I hope this helps.