Python time ctime() Method


Description

The Python time ctime() function converts a timestamp (a floating-point number calculated in seconds) into the form of time.asctime(). If the parameter is not given or is None, it defaults to time.time() as the parameter. Its effect is equivalent to asctime(localtime(secs)).

Syntax

ctime() method syntax:

time.ctime([ sec ])

Parameters

  • sec -- The number of seconds to be converted into a string time.

Return Value

This function has no return value.

Examples

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

#!/usr/bin/python
import time

print "time.ctime() : %s" % time.ctime()

The above example outputs:

time.ctime() : Tue Feb 17 10:00:18 2013
Other Extensions