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.

Table B.11. Date Formatting Codes
CodeDescriptionExample
%aAbbreviated weekday nameSun
%AFull weekday nameSunday
%bAbbreviated month nameJan
%BFull month nameJanuary
%dTwo-digit day of the month, zero-padded if necessary01
%eOne- or two-digit day of the month, space-padded if necessary1
%HTwo-digit hour using a 24-hour clock, zero-padded if necessary20 ...

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.