13.8.2. Date Format Strings

The Python documentation details the date format, however the strings used for strftime and strptime are built from the following directives.

Table 13.2. Date Format Directives

DirectiveMeaningExample
%dDay of the month as a zero-padded decimal number01, 02, ..., 31
%mMonth of the year as a zero-padded number01, 02, ..., 12
%y2-digit year as a zero-padded number00, 01, ... 99
%Y4-digit year as a zero-padded number0000, ..., 2020, ...., 9999
%H24-hour clock Hour as a zero-padded number00, 01, ..., 23
%I12-hour clock Hour as a zero-padded number00, 01, ..., 12
%pAM/PM (or local equivalent)AM, PM
%MMinute as a zero-padded number00, 01, ..., 59
%SSecond as a zero-padded number00, 01, ..., 59

Table 13.3. Common Examples of Date Strings

StringOutput Example
%Y-%m-%d2019-12-31
%H:%M:%S23:59:59
%m/%d/%y %H:%M:%S12/31/19 23:59:59