문제

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top