Formatting dates

I’ve seen the question pop up a few times over the last couple of years about how to format dates on blogs to show the ‘YC’ year, rather than the standard 2011 etc. Most recently, I saw Seismic Stan ask this question on Twitter, and I figure that rather than telling only him, it might be worth highlighting it here so others can see how to do it.

This post pertains specifically to WordPress installs that are self-hosted. I know how limited things are if you’re hosted at, but if you can edit the file I mention below, we’re golden. Other blogging platforms probably have something similar, so do a bit of research on where it outputs the date, because the syntax will be quite close as long as it uses PHP.

To illustrate what the goal is. We want to change this:

default WordPress date format

Into this:

Eve Online formated datestamp

The first thing you need to do is connect to your site by FTP, and navigate to wp-content/themes/YOURTHEMENAME/ and download the file loop-single.php If you only have loop.php use that. Some newer themes (like the pre-installed ‘Twenty Eleven’) have content-single.php instead. Just use that if you have no ‘loop’ files.

Anyway, once you have downloaded the file, fire up your favourite text editor. Something with syntax highlighting is preferable; Notepad++ is quite a good free one. I generally use Netbeans, but its a bit OTT for a simple change like this unless you already use it for projects. Open the file in the editor. You’re looking for the following text:


Now all you need to do is to change that text to this:

$yc = 'YC '.(date('Y') - 1898);
echo 'Posted on '.date('l jS F ').$yc;

But what does this do? Lets break it down!

  • All you’re doing here is saying that $yc contains the string for the date format, preceded by ‘YC’ (naturally). The YC year is always our current real-world year minus 1898 (2011 – 1898 = 113) so where we say date(‘Y’) – 1898, all we’re really doing is some basic mathematics on the current year output.
  • On the second line, we’re outputting some text and a full date – without the year – then appending our custom year to the end. The ‘l jS F’ part just tells PHP how to format the date. You can find a list of what you can use over at so its quite easy to play around and find one that you’re happy with.

I’d recommend trying out a few variations and see what you can come up with. WordPress keeps archives by month and year, so you could quickly create those portions of the date as handy links to the relevant archive pages if you wanted. Give it a go, and let me know if this helps at all! 😀

Comments for this Post

One thought on “Formatting dates”

  1. Pingback: Eve Online Archive: StarfleetComms Podcast Ep 15 | StarfleetComms

Leave a Reply

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