The timetuple() method of datetime.date instances returns an object of type time.struct_time. The struct_time is a named tuple object (A named tuple object has attributes that can be accessed by an index or by name).
The struct_time object has attributes for representing both date and time fields along with a flag to indicate whether Daylight Saving Time is active.
The named tuple returned by the timetuple() function will have its year, month and day fields set as per the date object and fields corresponding to the hour, minutes, seconds will be set to zero.
import datetime todaysDate = datetime.date.today() timeTuple = todaysDate.timetuple() print(timeTuple) print(timeTuple.tm_year)
This will give the output −
time.struct_time(tm_year=2017, tm_mon=12, tm_mday=28, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=362, tm_isdst=-1) 2017