How to modify wordpress time and date
- 3
- Add a Comment
This is a nifty little thing to know, and one of those annoying little feckers that will torment you if you don’t know how to change it
Walsho recently asked for help on this and said that he’d come to me for help - no worries Walsho, smemon to the rescue.
In admin panel, go to Presentation > Theme Editor (anytime you change your theme, you’ll have to do this).
Now click on ‘Main Index Template’ or ‘index page’ or something with the word ‘index’ in it, every theme is different.
Scroll down ’till you see the word time somewhere - STOP. (Here’s what the start of my file looks like, the red bit is the bit you’ll need to change).
<?php get_header(); ?>
<div id=”content”>
<?php if(have_posts()): ?>
<?php while(have_posts()) : the_post(); ?><div class=”post” id=”post-<?php the_ID(); ?>”>
<div class=”title”>
<h2><a href=”<?php the_permalink(); ?>” title=”Permanent link to <?php the_title(); ?>”><?php the_title(); ?></a></h2>
<?php the_time(”g:i a”); ?>, <?php the_time(”jS”); ?> <?php the_time(”M”); ?> <?php the_time(”Y”); ?>, posted in <small class=”categories”><?php the_category(’, ‘); ?></small><?php edit_post_link(’Edit Post’, ‘<span class=”editlink”>’, ‘</span>’); ?>
<span class=”comments”><?php comments_popup_link(’0 comments’, ‘1 comment’, ‘% comments’, ‘commentslink’); ?></span>
</div>
<div class=”entry”>
<?php the_content(’Read the rest of this entry »’) ?>
</div>
</div><!–
<?php trackback_rdf(); ?>
Simply translated, that bit in red = “1pm, 1st Jan 2008″ or something like that.
Say you want your time/date to display as “2008, Jan 1st, 1300″, you’d change that bit in red to;
<?php the_time(”Y”); ?>, <?php the_time(”M”); ?> <?php the_time(”jS”); ?>, <?php the_time(”g:i”); ?>
So basically you’re only editing the values in ” ” inverted commas.
Note: you may also have to change this in ‘page template’ or anywhere else the time function is displayed, as wordpress can be contrary if times don’t match up.
For a full list of values to put in those ” ” inverted commas, see the wordpress codex here.
WTF i hear you say
Since when did smemon become a codemonkey! Well, i *did* say i was reading up ebooks and trying to code and design wordpress themes… so i guess i’m learning something ![]()
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!







3 Comments
Link
January 4th, 2008
at 9:02pm
You can take this a bit farther and make it easier too.
the_time(”Y, M jS”)
The function the_time() works off of the PHP function called date (http://www.php.net/date) so you can use any of the formatting parameters listed on the php.net site. On my blog I use this:
the_time(”F jS, Y”)
Fixing my blog
January 4th, 2008
at 10:53pm
[...] time/date of posts. Again, thanks to smemon for “coming to my rescue” on this. I said yesterday I thought I knew the code to put in, and it turns out I did, but [...]
MokMitLoods
October 20th, 2008
at 11:01pm
Hi,
My Name is, James
verry cool site
check out my site:
http://YGHtJPVAM.spaces.live.com/