home ~ projects ~ socials

Python Date and Time Examples: ISO Format

Note, these don't include time zones

from datetime import datetime

now = datetime.now()

# with millilsecond
print(now.isoformat())


# without milliseconds
print(now.isoformat('T', 'seconds'))
-- end of line --

References