Python time gmtime() method
Python Time gmtime() Method
Description
The gmtime() method converts the number of seconds since the epoch to a struct_time structure in the UTC time zone, where the dst flag is always zero. If the secs argument is not provided or is None, the current time as returned by time() is used.
Syntax
The syntax of the gmtime() method is as follows:
time.gmtime([ sec ])
Parameters
- sec – This is the number of seconds to be converted to the
struct_time
representation.
Return Value
This method does not return any value.
Example
The following example shows the usage of the gmtime()
method.
import time
print ("gmtime :", time.gmtime(1681928297.5316436))
When we run the above program, it produces the following output.
gmtime : time.struct_time(tm_year=2023, tm_mon=4, tm_mday=19, tm_hour=18, tm_min=18, tm_sec=17, tm_wday=2, tm_yday=109, tm_isdst=0)