Showing posts with label Time gmtime() Method. Show all posts
Showing posts with label Time gmtime() Method. Show all posts

Sunday, March 11, 2018

Time gmtime() Method


 Time gmtime() Method in Python 3


The method gmtime() converts a time expressed in seconds since the epoch to a struct_time in UTC in which the dst flag is always zero. If secs is not provided or None,the current time as returned by time() is used.

Syntax

time.gmtime([ sec ])

Parameters
    sec - These are the number of seconds to be converted into structure struct_time representation.

Example

#!/usr/bin/python3
import time
print ("gmtime :", time.gmtime(1455508609.34375))

When we run the above program, it produces the following result-

gmtime : time.struct_time(tm_year=2018, tm_mon=3, tm_mday=11, tm_hour=20,
tm_min=45, tm_sec=40, tm_wday=6, tm_yday=70, tm_isdst=0)