This appendix is a quick reference for when you format dates and times in your Django templates. The following tables list the format characters that are available for the now tag and the date and time filters. Table C.1 describes the available format characters for formatting dates. Table C.2 describes the available options for formatting times.
Character | Description | Example |
---|---|---|
b | Month, textual, three letters, lowercase. | jan |
d | Day of the month, two digits with leading 0s. | 01 to 31 |
D | Day of the week, textual, three letters. | Mon to Sun |
F | Month, textual, long. | January |
j | Day of the month without leading 0s. | 1 to 31 |
l | Day of the week, textual, long. | Monday |
L | Boolean for whether it's a leap year. | True or False |
m | Month, two digits with leading 0s. | 01 to 12 |
M | Month, textual, three letters. | Jan to Dec |
n | Month, numeric, without leading 0s. | 1 to 12 |
N | Month in Associated Press style. Proprietary extension. | Jan., Feb., March, May |
r | RFC 822 formatted date. | Sat, 22 Sep 2007 18:12:05 +0700 |
S | English ordinal suffix for the day of the month, two characters. | st, nd, rd, th |
t | Number of days in the given month. | 28 to 31 |
w | Day of the week, numeric without leading 0s. | 0 (Sunday) to 6 (Saturday) |
W | ISO-8601 week number in the year, with weeks starting on Monday. | 1, 52 |
y | Year, numeric, two digits. | 08 |
Y | Year, numeric, four digits. | 2008 |
z | Day of the year, numeric. | 0 to 365 |