Hello I solved it
$the_query = new WP_Query( array(
'post_type' => array('town1_event','town1_event2'),
'post_status' => 'publish',
'meta_key' => 'datum_eventu',
'orderby' => 'meta_value_num',
'order' => 'ASC'
) );
# This will hold what group we're in
$current_header = '';
# The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
# get the datum for this post
$temp_date = get_post_meta( get_the_ID(), 'datum_eventu', true );
# If they aren't the same, we'll start a new group, which for now
# just means setting a new heading
if ( $temp_date != $current_header ) {
$current_header = $temp_date;
$old_date = date($current_header); // returns Saturday, January 30 10 02:06:34
$old_date_timestamp = strtotime($old_date);
$new_date = date('d.m.Y', $old_date_timestamp);
echo "<h2>$new_date</h2>";
}
$nazev = get_field("nazev_eventu");
echo $nazev;
echo "<br/>";
# ... do normal loop stuff here
endwhile;
Inspired on stack over flow