Python3 time mktime () method
description
Python time mktime () function performs gmtime (), localtime () reverse operation, which receives struct_time object as a parameter and returns a float to represent the number of seconds of time.
If the value entered is not a valid time, it will trigger OverflowError or ValueError.
grammar
mktime () method syntax:
time.mktime(t)
parameter
- t - structured time or full nine yuan set of elements.
return value
Returns the number of seconds used to represent floating point of time.
Examples
The following example shows mktime () function to use:
#!/usr/bin/python3 import time t = (2016, 2, 17, 17, 3, 38, 1, 48, 0) secs = time.mktime( t ) print ("time.mktime(t) : %f" % secs) print ("asctime(localtime(secs)): %s" % time.asctime(time.localtime(secs)))
The above example output is:
time.mktime(t) : 1455699818.000000 asctime(localtime(secs)): Wed Feb 17 17:03:38 2016