Use the ctime()
function
#import the time module
import time
#print the current time
print(time.ctime())
The time.ctime()
function converts seconds that represents a time since the epoch (January 1, 1970) into a human-readable format.
ctime(seconds = None)
The seconds
argument should be a float representing the seconds since the epoch to be converted into a human-friendly date. If not given the function returns the current local time.
print the current time
#import the time module
import time
now = time.ctime()
print(now)
print a future date
import time
now = time.time()
future = now + 6.312e+7
print("In two years it will be, ", time.ctime(future))
print a past date
import time
now = time.time()
past = now - 6.312e+7
print("Two years back, it was, ", time.ctime(past))