Skip to content

Instantly share code, notes, and snippets.

@junzis
junzis / python_time.py
Last active Oct 18, 2021
Time conversions in python
View python_time.py
from datetime import datetime
import time
#-------------------------------------------------
# conversions to strings
#-------------------------------------------------
# datetime object to string
dt_obj = datetime(2008, 11, 10, 17, 53, 59)
date_str = dt_obj.strftime("%Y-%m-%d %H:%M:%S")
print date_str