Customising the Date Format in Textpattern
With the release of my new design I wanted to use a short date format for my entries, however the default Textpattern install while having many different options didn’t have the exact one I wanted. A little hacking required but it was an easy fix, here is how I accomplished it.
If you open the
/textpattern/includes/txp_prefs.php file you will find on or around line 354 the
dateformats() function. In the
$formats array you can edit or delete any of the current options, I decided to create a couple of my own and added them to the top of the array:
"$daynumord $monthshort $yearshort",
"$daynumord $monthshort $yearshort $time24",
- Download this code: /code/txp_dateformat.txt
These are pretty self explanatory, the first displays the day, a short version of the month and a short version of the year. The second line displays the same thing except it adds on the time in 24 hour format to the end (for my archive).
That is all you need to do, save and reupload the file and now when you visit Admin > Preferences within Textpattern you will see your new options.
The only issue with hacking the file is that when you next update Textpattern your changes will be overwritten. Currently there is no decent plugin to accomplish this, hopefully there will be in the future so we do not have to hack the core Textpattern files.