Python Time Ctime() Method



Python time scheme ctime() changes a time stated in seconds since the era to a string in place of local time. If secs is not offered or None, the present time as revisited by time() is utilized. This purpose is corresponding to asctime(localtime(secs)). Locale information is not used by ctime().


Following is the syntax for ctime() method -

time.ctime([ sec ])


  • sec - These are the number of seconds to be converted into a string representation.

Return Value

This method does not return any value.


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

import time

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

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

time.ctime() : Tue Feb 17 10:00:18 2009

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.