Skip to content Skip to sidebar Skip to footer

How To Customize Date Format In Wordpress

I need to customize the date format in Wordpress. I know that minor date changes can be made from Dashboard << Settings << General << Date. But my needs are not f

Solution 1:

If I'm understanding your question correctly, one solution would be to wrap each part of the date in a different span class. So whenever you want to insert the date you would use something like the following:

<?php the_time('F', '<span class="month">', '</span>'); ?>&nbsp;<?php the_time('d', '<span class="day">', '</span>'); ?>

Then you can target these different span classes separately in your css.

.month {
    font-family:serif;
}
.day {
    font-family:sans-serif;
}

This will output a format that looks like this: April 11 where both the month and date can be styled separately however you want. You can display a different month/date format by changing what you pass into the_time() function. For example, changing the month code to <?php the_time('m', '<span class="month">', '</span>'); ?> will output Apr 11 instead.

There are a lot of different configurations for this and there's more info on that here http://codex.wordpress.org/Formatting_Date_and_Time

Post a Comment for "How To Customize Date Format In Wordpress"