646 | | Available format strings: |
647 | | |
648 | | ================ ======================================== ===================== |
649 | | Format character Description Example output |
650 | | ================ ======================================== ===================== |
651 | | a ``'a.m.'`` or ``'p.m.'`` (Note that ``'a.m.'`` |
652 | | this is slightly different than PHP's |
653 | | output, because this includes periods |
654 | | to match Associated Press style.) |
655 | | A ``'AM'`` or ``'PM'``. ``'AM'`` |
656 | | b Month, textual, 3 letters, lowercase. ``'jan'`` |
657 | | B Not implemented. |
658 | | c ISO 8601 Format. ``2008-01-02T10:30:00.000123`` |
659 | | d Day of the month, 2 digits with ``'01'`` to ``'31'`` |
660 | | leading zeros. |
661 | | D Day of the week, textual, 3 letters. ``'Fri'`` |
662 | | f Time, in 12-hour hours and minutes, ``'1'``, ``'1:30'`` |
663 | | with minutes left off if they're zero. |
664 | | Proprietary extension. |
665 | | F Month, textual, long. ``'January'`` |
666 | | g Hour, 12-hour format without leading ``'1'`` to ``'12'`` |
667 | | zeros. |
668 | | G Hour, 24-hour format without leading ``'0'`` to ``'23'`` |
669 | | zeros. |
670 | | h Hour, 12-hour format. ``'01'`` to ``'12'`` |
671 | | H Hour, 24-hour format. ``'00'`` to ``'23'`` |
672 | | i Minutes. ``'00'`` to ``'59'`` |
673 | | I Not implemented. |
674 | | j Day of the month without leading ``'1'`` to ``'31'`` |
675 | | zeros. |
676 | | l Day of the week, textual, long. ``'Friday'`` |
677 | | L Boolean for whether it's a leap year. ``True`` or ``False`` |
678 | | m Month, 2 digits with leading zeros. ``'01'`` to ``'12'`` |
679 | | M Month, textual, 3 letters. ``'Jan'`` |
680 | | n Month without leading zeros. ``'1'`` to ``'12'`` |
681 | | N Month abbreviation in Associated Press ``'Jan.'``, ``'Feb.'``, ``'March'``, ``'May'`` |
682 | | style. Proprietary extension. |
683 | | O Difference to Greenwich time in hours. ``'+0200'`` |
684 | | P Time, in 12-hour hours, minutes and ``'1 a.m.'``, ``'1:30 p.m.'``, ``'midnight'``, ``'noon'``, ``'12:30 p.m.'`` |
685 | | 'a.m.'/'p.m.', with minutes left off |
686 | | if they're zero and the special-case |
687 | | strings 'midnight' and 'noon' if |
688 | | appropriate. Proprietary extension. |
689 | | r RFC 2822 formatted date. ``'Thu, 21 Dec 2000 16:01:07 +0200'`` |
690 | | s Seconds, 2 digits with leading zeros. ``'00'`` to ``'59'`` |
691 | | S English ordinal suffix for day of the ``'st'``, ``'nd'``, ``'rd'`` or ``'th'`` |
692 | | month, 2 characters. |
693 | | t Number of days in the given month. ``28`` to ``31`` |
694 | | T Time zone of this machine. ``'EST'``, ``'MDT'`` |
695 | | u Microseconds. ``0`` to ``999999`` |
696 | | U Seconds since the Unix Epoch |
697 | | (January 1 1970 00:00:00 UTC). |
698 | | w Day of the week, digits without ``'0'`` (Sunday) to ``'6'`` (Saturday) |
699 | | leading zeros. |
700 | | W ISO-8601 week number of year, with ``1``, ``53`` |
701 | | weeks starting on Monday. |
702 | | y Year, 2 digits. ``'99'`` |
703 | | Y Year, 4 digits. ``'1999'`` |
704 | | z Day of the year. ``0`` to ``365`` |
705 | | Z Time zone offset in seconds. The ``-43200`` to ``43200`` |
706 | | offset for timezones west of UTC is |
707 | | always negative, and for those east of |
708 | | UTC is always positive. |
709 | | ================ ======================================== ===================== |
710 | | |
| 1071 | Available format strings: |
| 1072 | |
| 1073 | ================ ======================================== ===================== |
| 1074 | Format character Description Example output |
| 1075 | ================ ======================================== ===================== |
| 1076 | a ``'a.m.'`` or ``'p.m.'`` (Note that ``'a.m.'`` |
| 1077 | this is slightly different than PHP's |
| 1078 | output, because this includes periods |
| 1079 | to match Associated Press style.) |
| 1080 | A ``'AM'`` or ``'PM'``. ``'AM'`` |
| 1081 | b Month, textual, 3 letters, lowercase. ``'jan'`` |
| 1082 | B Not implemented. |
| 1083 | c ISO 8601 Format. ``2008-01-02T10:30:00.000123`` |
| 1084 | d Day of the month, 2 digits with ``'01'`` to ``'31'`` |
| 1085 | leading zeros. |
| 1086 | D Day of the week, textual, 3 letters. ``'Fri'`` |
| 1087 | f Time, in 12-hour hours and minutes, ``'1'``, ``'1:30'`` |
| 1088 | with minutes left off if they're zero. |
| 1089 | Proprietary extension. |
| 1090 | F Month, textual, long. ``'January'`` |
| 1091 | g Hour, 12-hour format without leading ``'1'`` to ``'12'`` |
| 1092 | zeros. |
| 1093 | G Hour, 24-hour format without leading ``'0'`` to ``'23'`` |
| 1094 | zeros. |
| 1095 | h Hour, 12-hour format. ``'01'`` to ``'12'`` |
| 1096 | H Hour, 24-hour format. ``'00'`` to ``'23'`` |
| 1097 | i Minutes. ``'00'`` to ``'59'`` |
| 1098 | I Not implemented. |
| 1099 | j Day of the month without leading ``'1'`` to ``'31'`` |
| 1100 | zeros. |
| 1101 | l Day of the week, textual, long. ``'Friday'`` |
| 1102 | L Boolean for whether it's a leap year. ``True`` or ``False`` |
| 1103 | m Month, 2 digits with leading zeros. ``'01'`` to ``'12'`` |
| 1104 | M Month, textual, 3 letters. ``'Jan'`` |
| 1105 | n Month without leading zeros. ``'1'`` to ``'12'`` |
| 1106 | N Month abbreviation in Associated Press ``'Jan.'``, ``'Feb.'``, ``'March'``, ``'May'`` |
| 1107 | style. Proprietary extension. |
| 1108 | O Difference to Greenwich time in hours. ``'+0200'`` |
| 1109 | P Time, in 12-hour hours, minutes and ``'1 a.m.'``, ``'1:30 p.m.'``, ``'midnight'``, ``'noon'``, ``'12:30 p.m.'`` |
| 1110 | 'a.m.'/'p.m.', with minutes left off |
| 1111 | if they're zero and the special-case |
| 1112 | strings 'midnight' and 'noon' if |
| 1113 | appropriate. Proprietary extension. |
| 1114 | r RFC 2822 formatted date. ``'Thu, 21 Dec 2000 16:01:07 +0200'`` |
| 1115 | s Seconds, 2 digits with leading zeros. ``'00'`` to ``'59'`` |
| 1116 | S English ordinal suffix for day of the ``'st'``, ``'nd'``, ``'rd'`` or ``'th'`` |
| 1117 | month, 2 characters. |
| 1118 | t Number of days in the given month. ``28`` to ``31`` |
| 1119 | T Time zone of this machine. ``'EST'``, ``'MDT'`` |
| 1120 | u Microseconds. ``0`` to ``999999`` |
| 1121 | U Seconds since the Unix Epoch |
| 1122 | (January 1 1970 00:00:00 UTC). |
| 1123 | w Day of the week, digits without ``'0'`` (Sunday) to ``'6'`` (Saturday) |
| 1124 | leading zeros. |
| 1125 | W ISO-8601 week number of year, with ``1``, ``53`` |
| 1126 | weeks starting on Monday. |
| 1127 | y Year, 2 digits. ``'99'`` |
| 1128 | Y Year, 4 digits. ``'1999'`` |
| 1129 | z Day of the year. ``0`` to ``365`` |
| 1130 | Z Time zone offset in seconds. The ``-43200`` to ``43200`` |
| 1131 | offset for timezones west of UTC is |
| 1132 | always negative, and for those east of |
| 1133 | UTC is always positive. |
| 1134 | ================ ======================================== ===================== |
| 1135 | |
| 1136 | .. versionadded:: 1.2 |
| 1137 | |
| 1138 | The ``c`` and ``u`` format specification characters were added in Django 1.2. |
| 1139 | |