Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to achieve the following look in the time format:

enter image description here

I have for now several issues,
First is that the month and year are not displayed at all, I use <?php the_date('D'); ?> <?php the_date('M'); ?> <?php the_date('Y'); ?> for start and only the day is shown,

Second - Are there WP functions I can use to

  • Get the month in 3 cap letters?
  • Get only 2 last digits of year?

Or I have to use my own PHP functions for that?

Also, it must be hard-coded in the theme, because otherwise it will mess up the design.

Update
I used <?php echo get_the_date('M'); ?> and I got all the times, but isn't the_date meant exactly for that?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

I believe all the info you need is in the PHP Manual for Date/Time. Also, it is recommended that you use get_the_date(); instead of the_date();

Get them month in 3 cap letters?

M is the right format character that outputs a short textual representation of a month (3 chars). Why can't you use CSS to capitalize all the three letters? I mean, text-transform: uppercase; should do it.

Get only 2 last digits of year?

Use the small y. It outputs two digit representation of a year.

EDIT (to answer the updated question)

The function reference for the_date(); in codex has a special note that says:

When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.

share|improve this answer

Your Answer

 
discard

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.