So it appears that YOU have to modify the value that your function is returning to you. Show us that function!
AND - stop switching into and out of PHP mode. Very, very, VERY confusing and difficult to follow. Use an echo to output your html code or read up on how to use HTMLDOCS for that purpose. Just because you CAN use the php on/off tags doesn't mean you have to.
foreach ( $r->posts as $recent_post )
$post_title = get_the_title( $recent_post->ID );
$title = ( ! empty( $post_title ) ) ? $post_title : __( '(no title)' );
$link = the_permalink( $recent_post->ID );
if ( $show_date )
$dt = get_the_date( '', $recent_post->ID );
echo "<span class='post-date'>$dt</span>";