Python Date and Time Examples: ISO Format

Note, these don't include time zones

Code

from datetime import datetime

now = datetime.now()

# with millilsecond
print(now.isoformat())


# without milliseconds
print(now.isoformat('T', 'seconds'))

References