Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Year Month & Day as Integers from an ISO 8601 Date String
date_str = "2017-01-29"
year_str = date_str[0] + date_str[1] + date_str[2] + date_str[3]
month_str = date_str[5] + date_str[6]
day_str = date_str[8] + date_str[9]
year_int = int(year_str)
month_int = int(month_str)
day_int = int(day_str)
print(year_int)
print(month_int)
print(day_int)
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.