datetime python convert time to seconds code example
Example 1: python datetime to seconds
from datetime import datetime
dt = datetime.today() # Get timezone naive now
seconds = dt.timestamp()
Example 2: Python3 seconds to datetime
>>> from datetime import datetime
>>> datetime.fromtimestamp(1485714600).strftime("%A, %B %d, %Y %I:%M:%S")
'Sunday, January 29, 2017 08:30:00'