Function Name:
isoformat
Function Signature:
isoformat()
Return Value:
Returns a string containing the date in ISO 8601 format.
Type:
Instance method.
Overview:
- The isoformat() method returns the date value of a Python datetime.date object in ISO 8601 format.
- The standard ISO 8601 is about date formats for Gregorian calendar. It prescribes that a calendar date to be represented using a 4-digit year followed by a two-digit month and a two-digit date. i.e., YYYY-MM-DD. Example: 2020-01-01.
Example:
import datetime import time
todaysDate = datetime.date.fromtimestamp(time.time()); dateISOFormat = todaysDate.isoformat(); print("Today's date in ISO Format:%s"%dateISOFormat); print(type(dateISOFormat)); |
Output:
Today's date in ISO Format:2019-07-12 <class 'str'> |