PyDocs

Nav

Data Types

time.strftime

datetime

method of time
  • time.strftime(format)
Format using strftime().

The date part of the timestamp passed to underlying strftime should
not be used.

For a list of supported format codes, see the documentation:
    https://docs.python.org/3/library/datetime.html#format-codes
1 Example
>>> import datetime as dt
>>> class TZ1(dt.tzinfo):
...     def utcoffset(self, when):
...         return dt.timedelta(hours=1)
...     def dst(self, when):
...         return dt.timedelta(0)
...     def tzname(self, when):
...         return "+01:00"
...     def  __repr__(self):
...         return f"{self.__class__.__name__}()"
...
>>> t = dt.time(12, 10, 30, tzinfo=TZ1())
>>> t
datetime.time(12, 10, 30, tzinfo=TZ1())
>>> t.isoformat()
'12:10:30+01:00'
>>> t.dst()
datetime.timedelta(0)
>>> t.tzname()
'+01:00'
>>> t.strftime("%H:%M:%S %Z")
'12:10:30 +01:00'
>>> 'The {} is {:%H:%M}.'.format("time", t)
'The time is 12:10.'
from the Python docs
See Also
No see-alsos for datetime/time.strftime
0 Notes
No notes for time.strftime