The fromordinal()
method is used to convert a Gregorian ordinal to an equivalent Gregorian date format. It is a reverse method of toordinal()
that takes a Gregorian date as an argument and returns an ordinal.
date.fromordinal(ordinal)
ordinal
: It takes an ordinal as an argument value.
It returns the date in Gregorian calendar format.
# Load datetime moduleimport datetime# Random ordinalordinal = 2141;# passing Gregorian ordinal to fromordinal() methoddate = datetime.date.fromordinal(ordinal);# Printing the Gregorian dateprint("Date Parallel to Gregorian Ordinal %d is: %s"%(ordinal, date))
datetime
library.ordinal
variable and assign a value to it.date.fromordinal
method.