Not a developer? Go to MovableType.com

Documentation

Date Formats

Movable Type lets you specify the exact formatting of dates and times that are displayed anywhere on your site. The system uses a simple code to represent the part of the time or date, as well as the specific display you’ve chosen. The default option, for example, is %x, which outputs date in the normal format for your region.

In US English, that represents %B %d, %Y, where %B is a full name of a month, like “September”, %d is the two-digit day of the month, with a leading “0” if needed, like “06”, and `%Y“ is the four-digit year, like “2007”.

The following date and time format codes can be used with any Movable Type tags that output a datetime

Common Formats

Using the mt:EntryDate tag as an example…

  • Dec 25, 2009

    <$mt:EntryDate format="%b %e, %Y"$>
    
  • Dec 25, 2009 11:56 PM

    <$mt:EntryDate format="%b %e, %Y %l:%M:%S %p"$>
    

    or the short format….

    <$mt:EntryDate format="%x %X"$>
    
  • 2009-12-25

    <$mt:EntryDate format="%Y-%m-%e"$>
    

Attributes


format

Recognized date and time format codes to be used with the format attribute:

General Codes

  • %x

    The language-aware standard date representation. For most languages, this is just the same as %B %d, %Y.

    <$mt:EntryDate format="%x"$> will output September 06, 2002
    
  • %X

    The language-aware time representation. For most languages, this is just the same as %I:%M %p.

    <$mt:EntryDate format="%X"$> will output 04:31 PM
    

Time Codes

  • %I

    The two-digit hour on a 12-hour clock padded with a zero if applicable. (uppercase “i”)

    <$mt:EntryDate format="%I"$> will output 04
    
  • %l

    The hour on a 12-hour clock padded with a space if applicable. (lowercase “L”)

    <$mt:EntryDate format="%I"$> will output 4
    
  • %H

    The two-digit 24-hour clock padded with a zero if applicable. Example: 16.

  • %k

    The two-digit 24-hour clock padded with a space if applicable. Example: 9.

  • %M

    The two-digits minute padded with a leading zero if applicable. Example: 02.

  • %S

    The two-digit second padded with a zero if applicable. Example: 04.

  • %p

    Either AM or PM. Language dependent.

Date Codes

  • %A

    The full weekday name. Example: Thursday.

  • %a

    The abbreviated weekday name. Example: Thu.

  • %B

    The full month name. Example: September.

  • %b

    The abbreviated month name. Example: Sep.

  • %m

    The two-digit month padded with a leading zero if applicable. Example: 09.

  • %d

    The two-digit day of the month padded with leading zeroes if applicable. Example: 09.

  • %e

    The day of the month space padded if applicable. Example: 9.

  • %Y

    The four-digit year. Example: 2001.

  • %y

    The two-digit year padded with a leading zero if applicable. Example: 01.

  • %j

    The three-digit day of the year padded with leading zeroes if applicable. Example: 040.

  • %w

    The numeric day of the week ranging from 0 to 6 where 0 is Sunday. Example: 0

language

Using the language attribute you can get the default language string for different languages.

The default output of <$mt:Date$> corresponds to the “Date Language” option in the blog’s Entry Settings.

For the English date string September 3, 2009 2:24 PM, use:

<$mt:Date language="en"$>

To get the Japanese date string 2009å¹´9月 3æ--¥ 14:24, use:

<$mt:Date language="ja"$>

If the ouput is not as desired, use the format attribute to make a custom string. The following is the same as <$mt:Date language="ja"$>:

<$mt:Date format="%Yå¹´%m月 %dæ--¥ %H:%M"$>

The following is a list of the recognized language codes:

  • cz - Czechoslovakian
  • dk - Scandinavian
  • nl - Dutch
  • en - English
  • fr - French
  • de - German
  • is - Icelandic
  • jp - Japanese
  • it - Italian
  • no - Norwegian
  • pl - Polish
  • pt - Portuguese
  • si - Slovenian
  • es - Spanish
  • fi - Finnish
  • se - Swedish

Technical details

All date and time tags inherit the two attributes that control their presentation.

Movable Type uses standard strftime format strings to describe date and time layouts using the format attribute. Furthermore, the language attribute can be used to override the weblog’s preferred language setting in weekday names, month names, and AM/PM codes. This override will apply only for the particular date string that you are formatting.

Note: As of version 2.0 of Movable Type, %Z is no longer supported. For the timezone see the MTBlogTimezone tag.

Back

5 Comments

Railwayman

Railwayman on January 19, 2010, 11:34 a.m. Reply

I wondered if a live time/date stamp could attributed to the search result listing by search engines such as google bot yahooslurp or msn/bing bot. If anyone has the answer to this please email or post here.

regards. Railwayman.

mathyou

mathyou on March 10, 2010, 9:16 a.m. Reply

I would love to see a setting to abbreviate or write out the full month based on AP Style: http://copyediting-grammar-style.suite101.com/article.cfm/howtowriteinap_style

Basically, months with short names should be written out while other months should be abbreviated.

Autohuur Kreta

Autohuur Kreta on July 20, 2012, 2:39 a.m. Reply

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.

Acai Beere

Acai Beere on August 29, 2012, 10:53 a.m. Reply

A standard date and time format string uses a single format specifier to define the text representation of a date and time value.

stephenb

stephenb on December 12, 2012, 10:54 a.m. Reply

@iwin.vn: There’s a whole section dedicated to dates in the documentation.

Leave a Comment