How to modify wordpress time and date

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 :twisted:

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 :mrgreen: 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 :twisted:

  • Link

    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”)

  • MokMitLoods

    Hi,
    My Name is, James
    verry cool site
    check out my site:

    http://YGHtJPVAM.spaces.live.com/

 

Your browser is out of date. It has security vulnerabilities and may not display all features on this site and other sites.

Please update your browser using one of modern browsers (Google Chrome, Opera, Firefox, IE 10).

X