Shortcode of a function

Build a string instead of directly outputting the contents.

$str="";
foreach ($postslist as $post) : setup_postdata($post); 
  $str .= '<div class="events">';
    $str .= '<p><strong>'.get_the_date().'</strong></p>';
    $str .= '<p><a href="'.get_permalink().'" title="'.esc_attr(get_the_title()).'">'.get_the_title().'</a></p>';
  $str .= '</div>';
endforeach;