As another example of a user-defined type,we’ll define a class called Time that records the time of day.The class definition looks like this:
“””Represents the time of day.
Time object for hour,minute and seconds:
import time # using time() to display time since epoch print ("Seconds elapsed since the epoch are : ",end="") print (time.time()) # using gmtime() to return the time attribute structure print ("Time calculated acc. to given seconds is : ") print (time.gmtime()) Output: Seconds elapsed since the epoch are : 1470121951.9536893 Time calculated acc. to given seconds is : time.struct_time(tm_year=2016, tm_mon=8, tm_mday=2, tm_hour=7, tm_min=12, tm_sec=31, tm_wday=1, tm_yday=215, tm_isdst=0)