Repository navigation
Expand file tree
/
Copy pathlib_datetime_strftime.txt
More file actions
37 lines (35 loc) · 2.1 KB
/
Copy pathlib_datetime_strftime.txt
File metadata and controls
37 lines (35 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Python's strftime directives
Note: Examples are based on datetime.datetime(2013, 9, 3, 9, 6, 5)
Code Meaning Example
%a Weekday as locale’s abbreviated name. Tue
%A Weekday as locale’s full name. Tuesday
%w Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. 2
%d Day of the month as a zero-padded decimal number. 03
%-d Day of the month as a decimal number. (Platform specific) 3
%b Month as locale’s abbreviated name. Sep
%B Month as locale’s full name. September
%m Month as a zero-padded decimal number. 09
%-m Month as a decimal number. (Platform specific) 9
%y Year without century as a zero-padded decimal number. 13
%Y Year with century as a decimal number. 2013
%H Hour (24-hour clock) as a zero-padded decimal number. 09
%-H Hour (24-hour clock) as a decimal number. (Platform specific) 9
%I Hour (12-hour clock) as a zero-padded decimal number. 09
%-I Hour (12-hour clock) as a decimal number. (Platform specific) 9
%p Locale’s equivalent of either AM or PM. AM
%M Minute as a zero-padded decimal number. 06
%-M Minute as a decimal number. (Platform specific) 6
%S Second as a zero-padded decimal number. 05
%-S Second as a decimal number. (Platform specific) 5
%f Microsecond as a decimal number, zero-padded on the left. 000000
%z UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).
%Z Time zone name (empty string if the object is naive).
%j Day of the year as a zero-padded decimal number. 246
%-j Day of the year as a decimal number. (Platform specific) 246
%U Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. 35
%W Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. 35
%c Locale’s appropriate date and time representation. Tue Sep 3 09:06:05 2013
%x Locale’s appropriate date representation. 09/03/13
%X Locale’s appropriate time representation. 09:06:05
%% A literal '%' character. %
Source: Python’s strftime documentation.