tags:

views:

38

answers:

1

I'm trying to convert

[16/Jan/2010:18:11:06 +0100] (common log format)

to a timestamp. How can I use strptime to convert this?

time zone can be different from +0100

+2  A: 
import time
log = '16/Jan/2010:18:11:06 +0100'
dt = time.strptime(log, '%d/%b/%Y:%H:%M:%S +0100')

Reference: http://docs.python.org/library/time.html#time.strptime

Python's timezone support is problematic and platform dependant.
See this post (see also its first part).

NullUserException
im having trouble converting timezone,python only defines named timezones. rest is no problem
damir
@damir: See my edited post
NullUserException