Fix or Change the Post Date Format in WordPress

Filed Under (WordPress, fix) by chris on Thursday, January 21st, 2010

Tagged Under : , ,

For quite sometime, the post date format has not bee what I wanted. It was displaying day-month-year ( 21-1-10). This was confusing some of my readers. I tried to change it in the WordPress dashboard under Settings, but it never made a difference. I searched for a solution and found several people had the same problem but no one actually had a good answer. However, one of the posts refered me to Customizing the Time and Date and while this was just the formatting of the date and time, it did give me a clue of what to look for.

WordPress is written in the programming language PHP. The date formatting functions in WordPress use PHP’s built-in date formatting functions. You can use the table of date format characters on the PHP website as a reference for building date format strings for use in WordPress.

Armed with this information, I went to my WordPress dashboard and clicked on Appearance and then Editor. Then I started going through the Template Theme files. Sure enough, I found <?php the_time(‘D, m-d-Y’) in the Main Index Template (index.php) file. So I went back to the Format  page to see what options I had and decided on the day, month-date-year for my format. So I changed <?php the_time(‘D, m-d-Y’) to <?php the_time(‘D, m-d-Y’) and then clicked on update. And as you can see, the dates of my posts, on the main page, now have the post date formatted the way I wanted.

The other place you can change the time and date format is in Single Post (single.php) which I did a little different that my main page. I decided to go with l, F jS, Y which will look like: Friday, January 22nd, 2010

UPDATE: I found a couple other places that needed to be changed in my theme. So here is a list of the files that I could change my date format in.

Archives (archive.php)

Comments (comment.php)

Main Index Template (index.php)

Single Post (single.php)

Hope this helps. If you have any questions, leave me a comment and I will try to help.

Comments:

There are (21) Comments for the Fix or Change the Post Date Format in WordPress

Post a comment

8 visitors online now
8 guests, 0 members
Max visitors today: 12 at 12:28 am UTC
This month: 25 at 09-06-2010 12:42 am UTC
This year: 165 at 01-11-2010 09:16 pm UTC
All time: 165 at 01-11-2010 09:16 pm UTC