maikelm maikelm - 2 years ago 205
Python Question

Python convert date string to timestamp

I need to convert string type Wed, 18 May 2016 11:21:35 GMT to timestamp, in Python. I'm using:

datetime.datetime.strptime(string, format)

But I don't want to specify the format for the date type.

Answer Source

But I like not specify the format for the date type.

Then, let the dateutil parser figure that out:

>>> from dateutil.parser import parse
>>> parse("Wed, 18 May 2016 11:21:35 GMT")
datetime.datetime(2016, 5, 18, 11, 21, 35, tzinfo=tzutc())
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download