The Strftime () method translates to a tuple or sreuct_time representing the time specified by the format parameter returned by Gmtime () or locatime () as a string.
When T is not set, the current time is returned using the LocalTime () method. The format must be a string. The exception valueerror is suspended if T is outside the allowable range of any field.
Grammar:
The following is the syntax for the Strftime () method:
Time.strftime (Format[,t]) Parameters:
- T---This is the time in seconds to format.
- Format----This is the instruction that will be used to format the given time. The following instruction can embed a format string
Instructions:
- %a-Abbreviated day of the week
- %A-The full day of the week
- %b-Abbreviated month name
- %B-Full month name
- %c-Preferred date and time representation
- %c-century value (year divided by 100, range from 00 to 99)
- %d-the day ordinal of the month (01?31)
- %d-Similar%m/%d/%y
- %e-Day of the month (1?31)
- %g-similar to%g, but no century
- %G-a year that corresponds to a 4-digit number of ISO weeks (see%V)
- %h-Similar to%b
- %H-hours, using 24-hour (00?23)
- %I-hours, using 12-hour (01?12)
- %j-which day of the year (001?366)
- %m-month (01?12)
- %M-min
- %n-line break
- %p-AM or PM based on a given time value
- %r-time in the morning and the afternoon sign: am/pm
- %r-time in hour notation
- %s-Sec
- %t-Tab
- %T-current time, equals%h:%m:%s
- %u-Weekday is a number (1 to 7), Monday = 1. Warning: on Sun Solaris Sunday =1
- %u-the number of weeks of the year, the first Sunday as the first day of the first week
- %V-The week of the year ISO 8601 (01 to 53), where the 1th week is at least 4 days in the year of the first week, Monday as the first day of the week
- %W-the number of weeks of the year, with the first day of the first week of Monday as the first
- %w-week for a decimal, Sunday =0
- %x-date representation with no time
- %x-No date preferred time representation
- %y-One year without century (range from 00 to 99)
- %Y-this year, including century
- %Z or%Z-time zone or name or abbreviation
- Percent-Text% character
|
1 |
time.strftime (
format
[, t])
|
The strftime function of the Python time module