You can format a date in the given format using the datetime.strftime
method and the pytz
library for timezone support. Here is an example code snippet:
main.py449 chars12 lines
Note that the strftime
format string specifies the desired output format as follows:
%B
: full month name (e.g. "October")%d
: day of the month (e.g. "13")%Y
: year (e.g. "2014")%I
: 12-hour format hour (e.g. "11")%M
: minute (e.g. "13")%S
: second (e.g. "00")%f
: microsecond (e.g. "000000")%p
: AM or PM%Z
: timezone abbreviation (e.g. "PDT")%z
: timezone offset from UTC (e.g. "-0700")gistlibby LogSnag