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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.