This methods returns a string containing date and time formatted on the base of the specific format descriptor passed with the format parameter.
Table below lists all descriptors that can be used with the Strftime method together with their meaning.
Each descriptor consists in a percent symbol followed by a lowercase or uppercase letter. Any other text in the format string is not interpreted and is returned unaltered. A percent sign in the format string must be escaped by using a percent sign in front of it.
The following script shows how to use the Strftime method and format descriptors.
now = time()
print(now.Strftime("%a %B %d, %Y ore %X") + "<br>\n")
print(now.Strftime("%d-%m-%y %X") + "<br>\n")
print(now.Strftime("%d/%m/%Y %I:%M %p") + "<br>\n")
print(now.Strftime("%x (day %j of the year)") + "<br>\n")
print(now.Strftime("%a %b %d/%y (%W-th week)") + "<br>\n")
This script, run at 15:50 on 30/7/2001, generated the following output:
Mon July 30, 2001 ore 15:50:20
30/07/2001 03:50 pm
Monday July 30 2001 (day 211 of the year)
Mon Jul 30/01 (31-th week)