Python time localtime() method
Description
The Python time localtime() function is similar to gmtime(); it formats a timestamp as local time. If the sec parameter is not provided, the current time is used for the conversion. 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 into a time.struct_time object.
Return Value
This function has no return value.
Example
The following example shows how to use the localtime() function:
Example
#!/usr/bin/python
import
time
"
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)