Sunday, March 11, 2018

Time ctime() Method


Time ctime() Method in Python 3


The method ctime() converts a time expressed in seconds since the epoch to a string representing local time. If secs is not provided or None, the current time as returned by time() is used. This function is equivalent to asctime(localtime(secs)).

Locale information is not used by ctime().

Syntax
time.ctime([ sec ])

Parameters
      sec - These are the number of seconds to be converted into string representation.
Return Value
This method does not return any value.

Example

#!/usr/bin/python3
import time
print ("ctime : ", time.ctime())

When we run the above program, it produces the following result
ctime: Sun Mar 11 20:57:34 2018