Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert ISO 8601 Date String to Integers in Python with the dateutil.parser
# REFERENCE: https://bit.ly/2xLIh6I
import dateutil.parser
# Datestring in ISO 8601 format
datetime_str = "2019-01-23T06:17:59.273519"
# Convert to datetime object
some_datetime_obj = dateutil.parser.parse(datetime_str)
# Get Year, Month, and Day as integers
print(some_datetime_obj.year)
print(some_datetime_obj.month)
print(some_datetime_obj.day)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.