1

I am fetching dates from db to display the dates on the dropdown menu. It is displaying based on id.I want to sort the data based on dates.I am now getting dates in the below order:

  Saturday, March 25
  Saturday, April 15
  Wednesday, April 5
  Saturday, May 6
  Saturday, April 29
  Wednesday, May 10
  Saturday, May 20

i need the data in below order:

  Saturday, March 25
  Wednesday, April 5
  Saturday, April 15
  Saturday, April 29
  Saturday, May 6
  Wednesday, May 10
  Saturday, May 20

the code

   $dates = \Drupal::service('custom_forms.custom_forms_service')->getDates();
   $datesObj = array("" =>"- Select -");
   foreach($dates as $date){
        $datesObj[$date->id] = $date->date;
    echo "<pre>";print_r($datesObj[$date->id]);
     }
     exit;

1 Answers1

0
SELECT id, name, form_id, DATE(updated_at) as date
  FROM wp_frm_items
  WHERE user_id = 11 && form_id=9
  ORDER BY updated_at DESC,id ASC

This will sort the records by date first, then by names More detail

Community
  • 1
  • 1
Rahul Prajapati
  • 426
  • 1
  • 4
  • 12