Title: Sort PHP array by datetime
Last modified: August 30, 2016

---

# Sort PHP array by datetime

 *  [daniish](https://wordpress.org/support/users/daniish/)
 * (@daniish)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sort-php-array-by-datetime/)
 * Hello,
 * I am using the following PHP code (that i did not write) to display a custom 
   menu on my homepage ([http://www.globexposure.net/blossoms/](http://www.globexposure.net/blossoms/)):
 *     ```
       <?php wp_nav_menu( array( 'theme_location' => 'home-menu', 'container_class' => 'home_menu_class' ) ); ?>
       ```
   
 * At present it displays the menu items in reverse alphabetical order.
 * I would like to sort the array into datetime order instead. Please can someone
   show me how?
 * Many thanks

Viewing 1 replies (of 1 total)

 *  [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/sort-php-array-by-datetime/#post-6602121)
 * Hi
 * Looking at:
 * [https://codex.wordpress.org/Function_Reference/wp_nav_menu#Parameters](https://codex.wordpress.org/Function_Reference/wp_nav_menu#Parameters)
 * There is not an option to sort menu items.
 * Secondly, menu items do not have a date/time associated with them. So even if
   you could sort, you could not sort by the date/time.
 * However, try this:
 * 1)
    Have you tried editing the menu and changing the order of the menu items?
 * 2)
    If these are all pages, edit each page and set Page attributes (Box on right
   side of editing screen) > Order for each page…
 * Hope this helps 🙂

Viewing 1 replies (of 1 total)

The topic ‘Sort PHP array by datetime’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [datetime](https://wordpress.org/support/topic-tag/datetime/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/sort-php-array-by-datetime/#post-6602121)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
