How can I wrap html around the output of the_time function?

My current code in functions.php:

echo '<div class="post_date">'.the_time('d', '<div class="month">', '</div>').the_time('F', '<div class="day">', '</div>').the_time('Y', '<div class="year">', '</div>').'</div>';

But it only returns:

Read More
20April2011

No html around it, why? how can I fix this?

Related posts

Leave a Reply

1 comment

  1. Please see this documentation for the usage about the_time(). You are not supposed to add html inside the parameter of the_time(). (edit: use get_the_time() with in string concatenation)

    To solve this, try this code:

    echo '<div class="post_date"><div class="month">'.get_the_time('F').'</div>'.'<div class="day">'.get_the_time('d').'</div><div class="year">'.get_the_time('Y').'</div></div>';
    

    edit: corrected to the use of get_the_time()