My cloud server logs time in this format:
[17/Dec/2011:09:48:49 -0600]
To read it into Python variables, I can say:
>>>str = '17/Dec/2011:09:48:49 -0600'
>>>import time
>>>print time.strptime(str,"%d/%b/%Y:%H:%M:%S -0600")
Result:
time.struct_time(tm_year=2011, tm-mon=12, tm=mday=17, tm_hour=9, tm_min=48, tm_sec=49, tm_wday=5, tm_yday=351, tm_isdst=-1)
or I can try
>>>mytime = time.strptime(str,"%d/%b/%Y:%H:%M:%S -0600")
>>>print mytime.tm_hour
Result:
9
What does the -0600
do? I expected it to adjust the hour value in the date time object? Is there a wildcard to use instead of hard-coding the -0600
?