March 09, 2004

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.

Outlook-like dates for MT - a PHP script so that you can use words like "today" or "yesterday" instead of the date.

Has this tutorial been helpful? Please consider linking to Learning Movable Type at . Thanks!

Posted by Elise Bauer on March 09, 2004 to Beginner Tips
| Email to a friend | Printer-friendly version

Email to a friend

Email this article to:

Your email address:

Message (optional):