Latest web development tutorials

Python time gmtime () method

description

Python time gmtime () function to convert a timestamp to UTC time zone (zone 0) of struct_time, sec optional parameter indicates the number of seconds since 1970-1-1. The default value time.time (), the function returns an object time.struct_time type. (Struct_time are objects defined in the module in time represents the time).

grammar

gmtime () method syntax:

time.gmtime([ sec ])

parameter

  • sec - converted to the number of seconds time.struct_time type object.

return value

This function has no return value.

Examples

The following example shows gmtime () function to use:

#!/usr/bin/python
import time

print "time.gmtime() : %s" % time.gmtime()

The above example output is:

time.gmtime() : time.struct_time(tm_year=2016, tm_mon=4, tm_mday=7, tm_hour=2, tm_min=55, tm_sec=45, tm_wday=3, tm_yday=98, tm_isdst=0)