If you change the saved date format to YYYY-MM-DD HH:MM
(always with leading zeroes). You can use the usort() array sorting function from php.
usort( $array, function( $a, $b ) {
return strcomp( $a['show_date_and_time'], $b['show_date_and_time'] );
} );
Without changing the date format you need a more complex compare callback:
usort( $array, function( $a, $b ) {
$date_a = date_create_from_format( 'j-m-Y H:i', $a['show_date_and_time'] );
$date_b = date_create_from_format( 'j-m-Y H:i', $b['show_date_and_time'] );
if ( $date_a > $date_b ) {
return 1;
} else if ( $date_a == $date_b ) {
return 0;
}
return -1;
} );
Related Posts:
- How to get WordPress Time Zone setting?
- Converting timestamps to local time with date_l18n()
- PHP function showing wrong time in WordPress
- Display sorting options dropdown when using WooCommerce product category shortcode
- Drop down+sort blog posts date added/most popular
- How to get year, month and hour in WordPress?
- What is the most efficient way to search users by their display name?
- Archive listing of posts by publish year (multiple years)
- Why does this echo values in the wrong order?
- WordPress returns a wrong date
- How to check for WordPress timezone type?
- Unable to set right time in admin and frontend template
- Sortable admin column for one meta key with three possible meta values
- Convert a date to ISO8601 date format
- wrong php date()?
- list posts and wrap them alphabetically A-Z
- Order posts randomly, not by date
- display month in french in wordpress/php?
- Displaying the Month and Year that a page was Created?
- Nesting if statements to echo only one string based on what tag was filtered?
- Get date numerical and separate?
- Sort posts by custom fields value using dropdown menu
- How to Sort posts by Vote Count?
- Sort query_posts for Parent Pages to menue order or the count?
- How to sort posts based on the value (number) of a post’s metadata?
- Sort custom meta column by other meta value
- Sort the result of the main Query in shop page by a custom taxonomy
- Print last modified date only on posts
- Sort by page information by Ascending Numbers
- Find hours between post_date and post_date_gmt
- 3 different times on my WordPress website
- How to keep track of when a vote is cast?
- How to get User Time Zone in WordPress?
- Check If Post Was Published More Than 6 Months Ago Using get_the_date
- How do I check or test a WordPress Auto Year Change Script?
- change the default order of posts only for specific categories
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- Shortcode function doesnt work without caption
- How to tag the main tag? [closed]
- Removing custom sort order from admin page listing
- Comparing Dates from custom field
- Get date function not working
- PHP time function ($today) for GMT +1
- Hide publish date when update date
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- How to detect and handle the time difference between server and user in WordPress?
- WordPress sorting posts by date and title using a dropdown
- No more get_option(‘date_time’) in WordPress 5.5?
- WordPress wrong dates bug
- How to pull date/time in french format for wordpress post?
- Can’t add to time? [closed]
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Ordering / grouping posts by datepicker ACF
- Adding a number to a date
- Display Year and Month from custom field + Age Calculator
- Page 2+ of taxonomy archives does not recognise sort-order from dropdown
- Query category-specific, paginated posts and allow viewer to change sort order
- Sort posts by title, sort array by largest number [duplicate]
- WordPress – show all posts + ones with specific tag
- Can i show items based on the day with php?
- ISOTOPE – Missing/Invalid Arguement Get Terms
- Posts sortable column not sorting properly for custom field numbers
- category & sub category order issues in wordpress
- Sort author list alphabetically
- Display Current Time using shortcode
- How do I convert a custom field to a php date format? [closed]
- Change date/time format in custom plugin
- Convert custom field date format to “WordPress default”
- What is wrong with my sorting logic?
- Date not working correctly
- Help getting previously visited pages ID
- How do I create a numbered list with PHP? [closed]
- Why in my theme I can’t see all the statics content under the posts?
- Woocommerce display one random product via php
- Display all pages – in order
- What does $_GET[‘iphone’] do?
- Change url tag name
- Backend of the WordPress.com [closed]
- Conditional using get_the_ID() not working [closed]
- Appended comments but they show up above the content instead of below
- get_template_directory adding FTP root folders in urls
- Custom ajax call returns 0 [duplicate]
- How to solve Woocommerce Memory Limit
- Metabox Not saving data
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Hide image if taxonomy term is empty
- Fatal error: Call to undefined function register_new_user()
- Shortcode to find and replace URL
- Remove the More Link
- Why is my str_replace not working on short code submitted by front-end?
- Detecting if parent page has gallery
- Skip foreach loop
- Displaying posts based on category
- stripping tags from excerpt in WordPress is not working
- Prev/Next Links Broken on Static Front Page Pagination
- Pagination broken on is_front_page()
- Changing the color scheme based on the url visited
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Mixing variables into an array when inserting values
- Don’t show certain div on front page?