Hi. I have timestamps that I am trying to convert to epoch time. An example:
[18/Nov/2014:05:19:56 +0000]
I am trying to convert this to an epoch timestamp but have one little glitch. I have this:
import time
date_time = '[18/Nov/2014:05:19:56 +0000]'
pattern = '[%d/%b/%Y:%H:%M:%S +0000]'
epoch = int(time.mktime(time.strptime(date_time, pattern)))
print epoch
As you can see, date_time includes a time zone spec of +0000. This is apparently not recognized. I do get output:
1416313196
However, this does not translate properly into the date I fed the Python script:
$ date -ud @1416313196
Tue Nov 18 12:19:56 UTC 2014
I believe that the Python script is not aware that the time in date_time is UTC. How do I get it to recognize that? Thank you.