Python 3 - time asctime() Method


Advertisements

Description

The method asctime() converts a tuple or struct_time representing a time as returned by gmtime() or localtime() to a 24-character string of the following form − 'Tue Feb 17 23:21:05 2009'.

Syntax

Following is the syntax for asctime() method −

time.asctime([t]))

Parameters

t − This is a tuple of 9 elements or struct_time representing a time as returned by gmtime() or localtime() function.

Return Value

This method returns 24-character string of the following form − 'Tue Feb 17 23:21:05 2009'.

Example

The following example shows the usage of asctime() method.

#!/usr/bin/python3
import time

t = time.localtime()
print ("asctime : ",time.asctime(t))

Result

When we run the above program, it produces the following result −

asctime :  Mon Feb 15 09:46:24 2016
python_date_time.htm
Advertisements