Copyright © tutorialspoint.com
This function converts a tuple or struct_time representing a time as returned by gmtime() or localtime() to a string as specified by the format argument.
If t is not provided, the current time as returned by localtime() is used. format must be a string. An exception ValueError is raised if any field in t is outside of the allowed range.
time.strftime(format[, t]) |
Here is the detail of parameters:
t: This is the time in number of seconds to be formatted.
format: This is the directive which would be used to format given time. The following directives can be embedded in the format string.
#!/usr/bin/python import time t = (2009, 2, 17, 17, 3, 38, 1, 48, 0) t = time.mktime(t) print time.strftime("%b %d %Y %H:%M:%S", time.gmtime(t)) |
This produces following result:
Feb 18 2009 00:03:38 |
Copyright © tutorialspoint.com