Skip to content

Instantly share code, notes, and snippets.

@joonro
Last active January 15, 2018 19:55
Show Gist options
  • Save joonro/7d19b537f77594f8ca923782da04a1f7 to your computer and use it in GitHub Desktop.
Save joonro/7d19b537f77594f8ca923782da04a1f7 to your computer and use it in GitHub Desktop.
[Convert datetime to string using type-specific formatting] https://docs.python.org/3.6/library/string.html #python #date #string
>>> import datetime
>>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
'2010-07-04 12:15:58'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment