Convert datetime format into seconds

datetime, python

Solution

Here's how you can do it:

>>> from datetime import datetime
>>> import time
>>> s = "16/08/2013 09:51:43"
>>> d = datetime.strptime(s, "%d/%m/%Y %H:%M:%S")
>>> time.mktime(d.timetuple())
1376632303.0

Also see Python Create unix timestamp five minutes in the future.

Problem

My date is in the format `DD/MM/YYYY HH:MM:SS` , ie `16/08/2013 09:51:43` . How can I convert the date into python seconds using `total_seconds()` or using any other python function?

Original source

Related problems