Formatting Dates
The codes shown in Table B.11 can be used in any date formatting string, such as the format attribute of date-related template tags. For example, to create a date such as “01-Jan-2010,” you could use a formatting string like this one:
%d-%b-%Y
The actual values of some of the codes depend on the language specified for the weblog, or for the tag in question with a language attribute.
Code | Description | Example |
---|---|---|
%a | Abbreviated weekday name | Sun |
%A | Full weekday name | Sunday |
%b | Abbreviated month name | Jan |
%B | Full month name | January |
%d | Two-digit day of the month, zero-padded if necessary | 01 |
%e | One- or two-digit day of the month, space-padded if necessary | 1 |
%H | Two-digit hour using a 24-hour clock, zero-padded if necessary | 20 ... |
Get Sams Teach Yourself Movable Type in 24 Hours now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.