Python Time Localtime() Method



Pythom time technique localtime() is alike to gmtime() except it adopts a number of seconds to the restricted time. If secs is not offered or None, the present time as revisited by time() is utilized. The DST ensign is set to 1 when DST applies to the agreed time.


Following is the syntax for localtime() method:

time.localtime([ sec ])


  • sec − These are the number of seconds to be converted into structure struct_time representation.

Return Value

This method does not return any value.


The following example shows the usage of localtime() method.

import time

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

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

time.localtime() : (2009, 2, 17, 17, 3, 38, 1, 48, 0)

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.