I have some IIS(Internet Information Service) logs that I need to process, something like the Apache web log if you are a Linux server guy.
The web logs starts with:
49.76.xx.xx - - [01/Jun/2015:00:01:08 -0500] "GET...
And I am curious about the timestamp, [01/Jun/2015:00:01:08 -0500]
, what does 0500 mean in this scenario? is it something like the timezone or offset based on this python documentation?
This is what I have done so far but it doesn't work:
from datetime import datetime
text = "01/Jun/2015:00:01:08 +0500"
print datetime.strptime(text, '%d/%b/%Y:%H:%M:%S %z')
And here is the error message.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-10-e243ceb157eb> in <module>()
1 from datetime import datetime
2 text = "01/Jun/2015:00:01:08 +0500"
----> 3 print datetime.strptime(text, '%d/%b/%Y:%H:%M:%S %z')
/opt/local/anaconda/lib/python2.7/_strptime.pyc in _strptime(data_string, format)
315 del err
316 raise ValueError("'%s' is a bad directive in format '%s'" %
--> 317 (bad_directive, format))
318 # IndexError only occurs when the format string is "%"
319 except IndexError:
ValueError: 'z' is a bad directive in format '%d/%b/%Y:%H:%M:%S %z'