[Tutor] Through a glass, darkly: the datetime module

Richard D. Moores rdmoores at gmail.com
Sun Oct 7 04:37:39 CEST 2012


On Sat, Oct 6, 2012 at 5:22 PM, eryksun <eryksun at gmail.com> wrote:

>     >>> from datetime import date
>     >>> date(2014, 2, 18).strftime("%A")
>     'Tuesday'
>
> http://docs.python.org/library/datetime#strftime-and-strptime-behavior

Or for Python 3.3,
<http://docs.python.org/py3k/library/datetime.html?highlight=strftime#strftime-strptime-behavior>.

I remain bewildered. Where did these strangely named things come from,
strftime and strptime? I see that

>>> from datetime import date
>>> date(2014, 2, 18).strftime("%A")
'Tuesday'

gives me what I was after, but I need to understand it, and I
understand very little of that section, "8.1.8. strftime() and
strptime() Behavior".

Take the first sentence in that section:
"date, datetime, and time objects all support a strftime(format)
method, to create a string representing the time under the control of
an explicit format string. Broadly speaking, d.strftime(fmt) acts like
the time module’s time.strftime(fmt, d.timetuple()) although not all
objects support a timetuple() method."

Total gibberish. I feel like I've hit a brick wall. Where can I go to
learn to understand it? I need some very basic, specific information.

Dick


More information about the Tutor mailing list