Sunday, March 11, 2018

Time localtime() Method


Time localtime() Method in Python 3


The method localtime() is similar to gmtime() but it converts number of seconds to local time. If secs is not provided or None, the current time as returned by time() is used. The dst flag is set to 1 when DST applies to the given time.

Syntax
time.localtime([ sec ])

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

Example

#!/usr/bin/python3
import time
print ("time.localtime() : %s" , time.localtime())

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

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