Python time localtime() Method
Description
The Python time localtime() function is similar to gmtime() and is used to format a timestamp as local time. If the sec parameter is not provided, the current time is used as the conversion standard. The DST (Daylight Savings Time) flag (-1, 0 or 1) indicates whether it is daylight saving time.
Syntax
localtime() method syntax:
time.localtime([ sec ])
Parameters
- sec -- The number of seconds to convert to an object of type time.struct_time.
Return Value
This function has no return value.
Examples
The following example demonstrates how to use the localtime() function:
Example
#!/usr/bin/python
import time
print "time.localtime() : %s" % time.localtime()
The output of the above example is:
time.localtime() : time.struct_time(tm_year=2016, tm_mon=11, tm_mday=27, tm_hour=10, tm_min=26, tm_sec=5, tm_wday=6, tm_yday=332, tm_isdst=0)Other Extensions