title: Sort WP_Query by ACF Datepicker
body: <p>I have a “Upcoming Events” page, and a “Past Events” page. Each event has a custom field called “event_date”.</p>
  
  <p>I want to create a loop that displays all of the events greater than today. I've taken a look through these articles, but couldn't get it to work:
  <a href="http://support.advancedcustomfields.com/forums/topic/how-do-i-filter-and-sort-event-posts-with-start-and-end-date/" rel="nofollow noreferrer">http://support.advancedcustomfields.com/forums/topic/how-do-i-filter-and-sort-event-posts-with-start-and-end-date/</a></p>
  
  <p><a href="https://wordpress.org/support/topic/plugin-advanced-custom-fields-sorting-by-date-picker" rel="nofollow noreferrer">https://wordpress.org/support/topic/plugin-advanced-custom-fields-sorting-by-date-picker</a></p>
  
  <p><a href="https://stackoverflow.com/questions/18576092/wordpress-advanced-custom-fields-order-posts-by-date-picker">wordpress advanced custom fields order posts by date-picker</a></p>
  
  <p>From what I’ve gathered in the three links above, I would put this in my functions.php file:</p>
  
  <pre><code>    // CREATE UNIX TIME STAMP FROM DATE PICKER
  function custom_unixtimesamp ( $post_id ) {
      if ( get_post_type( $post_id ) == 'event_type' ) {
      $event_date = get_post_meta($post_id, 'event_date', true);
  
          if($event_date) {
              $dateparts = explode('/', $event_date);
              $newdate1 = strtotime(date('d.m.Y H:i:s', strtotime($dateparts[1].'/'.$dateparts[0].'/'.$dateparts[2])));
              update_post_meta($post_id, 'unixstartdate', $newdate1  );
          }
      }
  }
  add_action( 'save_post', 'custom_unixtimesamp', 100, 2);
  </code></pre>
  
  <p>Then I would add something like this to my page template:</p>
  
  <pre><code>&lt;?php 
  $today = time();
  $args = array(
          'post_type' =&gt; 'event_type',
          'posts_per_page' =&gt; 5,
          'meta_query' =&gt; array(
              array(
              'key' =&gt; 'unixstartdate',
              'compare' =&gt; '&gt;=',
              'value' =&gt; $today,
              )
          ),
          'meta_key' =&gt; 'event_date',
          'orderby' =&gt; 'meta_value',
          'order' =&gt; 'ASC',
      );
  
  $query = new WP_Query( $args );
  $event_type = $query-&gt;posts;
  ?&gt;
  
  &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;
  </code></pre>
  
  <p>Right now that’s not turning up any results. My post-type is called “event_type”, and the key is “event_date”.</p>
  
  <p>Any thoughts on where I’m going wrong?</p>