PyDocs

Nav

Data Types

time.isoformat

datetime

method of time
  • time.isoformat(timespec='auto')
Return the time formatted according to ISO.

The full format is 'HH:MM:SS.mmmmmm+zz:zz'. By default, the
fractional part is omitted if self.microsecond == 0.

The optional argument timespec specifies the number of additional
terms of the time to include. Valid options are 'auto', 'hours',
'minutes', 'seconds', 'milliseconds' and 'microseconds'.
Changed in 3.6
  • 3.6: Added the timespec parameter.
1 Example
>>> import datetime as dt
>>> dt.time(hour=12, minute=34, second=56, microsecond=123456).isoformat(timespec='minutes')
'12:34'
>>> my_time = dt.time(hour=12, minute=34, second=56, microsecond=0)
>>> my_time.isoformat(timespec='microseconds')
'12:34:56.000000'
>>> my_time.isoformat(timespec='auto')
'12:34:56'
from the Python docs
See Also
No see-alsos for datetime/time.isoformat
0 Notes
No notes for time.isoformat