Quantcast
Channel: Convert string "Jun 1 2005 1:33PM" into datetime - Stack Overflow
Viewing all articles
Browse latest Browse all 55

Answer by SuperNova for Convert string "Jun 1 2005 1:33PM" into datetime

$
0
0

Python >= 3.7

to convert YYYY-MM-DD string to datetime object, datetime.fromisoformat could be used.

from datetime import datetimedate_string = "2012-12-12 10:10:10"print (datetime.fromisoformat(date_string))2012-12-12 10:10:10

Caution from the docs:

This does not support parsing arbitrary ISO 8601 strings - it is only intended as the inverse operation of datetime.isoformat(). A more full-featured ISO 8601 parser, dateutil.parser.isoparse is available in the third-party package dateutil.


Viewing all articles
Browse latest Browse all 55

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>