Python time asctime() Method


Description

The Python time asctime() function accepts a time tuple and returns a readable 24-character string in the form "Tue Dec 11 18:07:14 2008" (Tuesday, December 11, 2008, 18:07:14).

Syntax

Syntax of the asctime() method:

time.asctime([t]))

Parameters

  • t -- A tuple of 9 elements or a time value returned by the functions gmtime() or localtime().

Return Value

Returns a readable 24-character string in the form "Tue Dec 11 18:07:14 2008" (Tuesday, December 11, 2008, 18:07:14).

Examples

The following example demonstrates how to use the asctime() function:

#!/usr/bin/python
import time

t = time.localtime()
print "time.asctime(t): %s " % time.asctime(t)

The output of the above example is:

time.asctime(t): Tue Feb 17 09:42:58 2009
Other Extensions