Function Name
fromisoformat
Function Signature
@classmethod fromisoformat(date_string)
Parameters
date_string – The date string in ISO format – yyyy-mm-dd
Function Overview
- The class method fromisoformat() from the date class of Python datetime module, constructs a date object from a string containing date in ISO format. i.e., yyyy-mm-dd.
Example
# Example Python program that constructs a date object
# from a string containing a date in ISO format. i.e., YYYY-DD-MM
import datetime
# Birth day of Picaso
birthday_Picaso = "1881-10-25"
# Construct a datetime.date object
picasoBirthDate = datetime.date.fromisoformat(birthday_Picaso)
print("Birth day of Picaso: %s"%picasoBirthDate)
# Print the type
print(type(picasoBirthDate))Output
Birth day of Picaso: 1881-10-25
<class 'datetime.date'>