The Movable Type User Manual

NOTE: This documentation is for Movable Type 3.2. If you are using a newer version, please see the documentation for Movable type 3.3x or Movable Type Enterprise.

« Applying a Global Filter to Tag Output | Up | Introduction »

Chapter 3: Templates and Layout

Formatting a Date

Problem

You want to format the timestamp of a date tag.

Solution

Use the format attribute with the Date Tag Format codes.

Discussion

Movable Type provides added functionality to tags that handle date and time information. These tags will recognize a format attribute that defines the explicit date/time format to output. These formats are based on the strftime utility found on all Unix systems. A complete listing of the codes can be found in Appendix C.

For instance, if you were to insert this template markup into the context of an entry:

 <$MTEntryDate format="%B %e, %Y %l:%M %p"$>
 <$MTEntryDate format="%A"$>
 <$MTEntryDate format="%H:%m"$>

Although the MTEntryDate tag will always retrieve the same value, it will be formatted in three different ways. The output of these tags would look something like:

 April 22, 2005 3:26 PM
 Friday
 15:26

Typically these tags have "date" in their name, however you should consult the Appendix A about whether or not the format attribute applies to a given tag.

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated; but please do not use the feedback form to submit support requests or question. We will not respond to or publish such queries submitted through this form. If you have a technical question or problem, visit Movable Type Support.

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.