• Hi,

    I have changed the innerworkings of my theme to be able to make it a bit more flexible. No I have been presented a bit of a problem.
    One of the modules is a event module that shows on the archive page all the events per day.

    In the old situation it was just a custom field with date formatted as Y-m-d but now i have changed this to a unixtimestamp with time.

    My old code was able to get query all the posts for a specific date:

    <?php
            $today = date('Y-m-d H:i:s');
            $newdate = date('Y-m-d', strtotime($today . " +{$i} day"));
            $args = array(
    	                'numberposts'	=> -1,
    	                'post_type'		=> 'post_type_agenda',
    	                'meta_key'		=> 'begin_datum_en_tijd',
    	                'orderby'       => 'begin_datum_en_tijd',
    	                'meta_query' => array(
                                array(
                                    'key' => 'begin_datum_en_tijd',
    				'value' => $newdate,
    				'compare' => 'LIKE'
    			    )
    	     )
            );
            $the_query = new WP_Query( $args );

    But now the time is also included in the timestamp, so I cant compare with a ‘LIKE’.
    How is it possible to convert the value of the key to the Y-m-d format before the comparision…

    Thanks,

    Sem

  • The topic ‘meta_query compare unix timestamp’ is closed to new replies.