« Translation Services | Main | Previous Entries and Lastn »

Date Formats

The default Movable Type templates place the date that an entry is posted near the title of the entry and a time posted at the end of the entry. You can easily change the formatting of how these dates appear by changing the MTEntryDate tag in your index and archive templates.

The default date format that appears near the title of an entry looks like this:

February 15, 2004

The MTEntryDate tag that generates this date and format looks like this:

<$MTEntryDate format="%x"$>

What follows "format=" is what determines the format of the date and time displayed. The Movable Type User's Manual has a long list of all the different date strings (the bits of code that follows "format=") and the date formats they generate. Here's a table summarizing the most popular:

February 15, 2004 <$MTEntryDate format="%x"$>
Feb 15, 2004 <$MTEntryDate format="%b %e, %Y"$>
Feb 15, 04 <$MTEntryDate format="%b %e, %y"$>
Sunday, Feb 15 <$MTEntryDate format="%A, %b %e"$>
02/15/04 <$MTEntryDate format="%m/%e/%y"$>
15 February 2004 <$MTEntryDate format="%e %B %Y"$>
Feb 15, 2004 7:00 AM <$MTEntryDate format="%b %e, %y %I:%M %p"$>

To change the way a date appears on your weblog, find the places on the main index template and the archive templates where the date tag occurs. Change the tag using the format attribute strings as shown above. Save and rebuild the template.

Note: There is another MT date tag - MTDate which gives the date of the last time an entry was rebuilt. MTEntryDate gives the date that the entry was originally authored.

Comments (4)

I have a question: is it possible to format date like this:

"Feb 15, 2004 19:00"

instead of

"Feb 15, 2004 7:00 AM"?

Thanks to Google smartness, your entry is the first at the SERP page.

Hi Rostislav,

The MT Manual section on date formats shows %k as the code for using what we would call military time, or a 24 hour clock time.

So the format would be:

<$MTEntryDate format="%b %e, %y %k:%M %p"$>

Is it possible to change the display setting in the date archive listing? From January 2007 to 01 2007? That way I could put the Chinese character for month after the numeral 1.

Hi Clark -

You can't change the pre-populated archive options (at least not easily, that's really another subject), but you can specify your own archive specifiers using the link Elise provided. Here is the most recent appendix on date and time formats. You can also use archive file path specifiers (shorthand versions, such as %m for the two-digit month).

Post a comment

(If you haven't left a comment here before, your comment may need to be approved before will appear on the entry. Thanks for waiting.)