how to convert date-time to epoch in python?
<p>I want this particular date-time to be converted to epoch but it is giving me format error. what format should i use to do the following so that it can be json rendered. "2016-10-14 14:34:14+00:00". I am using python 2.7 and django 1.10</p>

<pre><code>stra = "instance[0].Timing"
formata = "%Y-%m-%d %H:%M:%S+00:00"
timing = calendar.timegm(time.strptime(stra, formata))
     return HttpResponse(json.dumps(
           {'result': 'True'
            'timing': timing,
            }))
</code></pre>

<p>Option 1, you can use <code>isoformat()</code>:</p>

<pre><code>from datetime import datetime

print(datetime.utcnow().isoformat())
# '2016-10-19T03:39:40.485521'
</code></pre>

<p>Option 2, <code>strftime()</code>, do not confuse it with <code>strptime</code>:</p>

<pre><code>print(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S+00:00'))
# '2016-10-19 03:42:58+00:00'
</code></pre>

python json django datetime epoch