In your sample code the $latest_posts
is an instance of WP_Query class.
If you want to get the latest post’s date, you should do this:
$latest_posts = new WP_Query( $args );
$last_date="";
if ( $latest_posts->have_posts() ) {
$latest_posts->the_post();
$last_date = get_the_date();
}
return $last_date;