I’m in wordpress, trying to format the date output. This is the code I’m using at present:
<div class="date"><?php the_date('M, Y'); ?></div>
It’s output looks like this:
MAY, 2010
What I want to do is have the date display like this (The month on top of the year):
MAY
2010
I’m just not familiar enough with PHP to get things working. A simple line break wouldn’t quite be sufficient because I want to play with sizing, placement of each separately (month text larger than the year text, both centered, etc.). Separate classes applied to each would be ideal.
mmmm… I did some more searching and, while I still don’t know how to get the “the date” function to display multiple lines correctly, using the “the time” function seems to do the same thing without breaking. Here’s the code I’m using. Works great.
You can then set the spans to
display: block
if you want them to each be on their own line:Actually, a line break is a good place to begin:
And then add additional CSS as needed. For example, if you then add div’s, it becomes apparent that the line break can go away, since separate div’s will break on their own as long as the
display:
property on the parent div (#date) isblock
.e.g.:
you should be able to just do
or any other tags making sure you escape the characters listed here
Put this in your themes functions.php and customize with instructions from http://codex.wordpress.org/Formatting_Date_and_Time
And then use
where you want the date to show up.