Dates support calendar arithmetic : Date Time « Development « Python






Dates support calendar arithmetic

Dates support calendar arithmetic

from datetime import date


birthday = date(1964, 7, 31)
now = date(2006, 7, 31)

age = now - birthday
print age.days


 
           
       








Related examples in the same category

1.Use time structureUse time structure
2.Dates are easily constructed and formattedDates are easily constructed and formatted
3.Print out a date, given year, month, and day as numbersPrint out a date, given year, month, and day as numbers
4.Define your own class to store time and date
5.Define class to use system time class