Python time asctime() method
Python Time asctime() Method
Description
The asctime() method converts a time represented by a tuple or struct_time structure returned by gmtime() or localtime() to a 24-character string of the form: ‘Tue Feb 17 23:21:05 2009’.
Syntax
The syntax of the asctime() method is as follows:
time.asctime([t]))
Parameters
- t – This is a 9-element time tuple or a struct_time structure returned by the gmtime() or localtime() functions.
Return Value
This method returns a 24-character string in the following format: ‘Tue Feb 17 23:21:05 2009’.
Example
The following example demonstrates the use of the asctime() method.
import time
t = time.localtime()
print ("asctime : ", time.asctime(t))
When we run the above program, we get the following output −
asctime : Wed Apr 19 23:50:25 2023