WordPress the_date vs. the_time

Hi !

This article is a friendly reminder for those like me, who can’t remember which wordpress function is used when.

Like the article title says is about the_date and the_time , because I wanted to make a post date look something like this:displaying the date on two rows. Like any “partially educated” web developer I wanted to achieve this by using the_date function with different parameters, like this:

<div class="post-date">
	<div class="month"><?php the_date(M) ?></div>
	<div class="day"><?php the_date(d) ?></div>
</div>

and then I discovered that it doesn’t work like I wanted to; the problem is that the second instance of the_date doesn’t work, is returning nothing, therefor just the month, no day … no good.

Lucky for me, I didn’t overload my brain too much trying to understand why is not working, and I gave another try, this time with the_time function, and … voilĂ  ! , worked like a charm.

<div class="post-date">
	<div class="month"><?php the_time(M) ?></div>
	<div class="day"><?php the_time(d) ?></div>
</div>

So keep in mind !

Leave a Reply

Your email address will not be published. Required fields are marked *

− 4 = 1

This site uses Akismet to reduce spam. Learn how your comment data is processed.