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?
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.