Reputation: 2383
I have a bunch of human-readable dates and times (to be specific, the default format in nginx logs) that I wish to convert to Unix timestamps. The format is like this:
04/Dec/2013:18:56:05 +0000
What's the most reliable way of doing this? Are there any libraries I can use for this purpose?
Upvotes: 1
Views: 3518
Reputation: 22669
I think you are looking for datetime.strptime
.
From the doc link
The datetime.strptime() class method creates a datetime object from a string representing a date and time and a corresponding format string.
Call it like
datetime.strptime(date_string, format)
Upvotes: 7