WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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

share|improve this question
up vote 1 down vote accepted

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()

share|improve this answer
That created the correct html, but the time was still outside of it. – Ezra Nov 13 '11 at 13:19
please use get_the_time() for usage in strings - codex.wordpress.org/Function_Reference/get_the_time – Michael Nov 13 '11 at 14:38
@Michael, perfect! Unix timestamp would be perfect! Post that as answer for an accept! :D – Ezra Nov 13 '11 at 23:11
I have edited the existing answer for you to accept. – Michael Nov 14 '11 at 11:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.