Changing How WordPress Displays the Date and Time

If you’ve had a blog for any length of time you’ll be hard pressed not to play around with it and mould it to your own needs. Even if you find a theme that you like, there will always be the odd thing that you want to change.

In my case, I wanted to change how the date and time were displayed on my blog posts – it was just a bit too “American” for my tastes. WordPress allows you to change the default date and time formats, (it’s under Options), but changing this had no effect. Obviously, the time and date formats were hard-coded into the theme files.

So I fired up my FTP program and downloaded copies of archive.php (displays the archive pages), single.php (displays a single post per page – basically the permalink page), and index.php (displays the main home page).

WordPress uses a specific function for displaying the date and time. So it was just a matter of searching each file for:

<?php the_time('F j, Y '); ?>

This displays the date as:

December 14, 2007

I changed the code to the following:

<?php the_time('l, jS F, Y'); ?>

which displays the date as follows:

Friday, 14th December, 2007

If you need a description of what the different parameters mean, then you can find more information from the WordPress Documentation Site and from the PHP Manual.