Python – time.ctime() Method
Python time.ctime() method converts a time in seconds since the epoch to a string in local time. This is equivalent to asctime(localtime(seconds)). Current time is returned by localtime() is used when the time tuple is not present.
Syntax: time.ctime([ sec ])
- sec: number of seconds to be converted into string representation.
Let’s move to the code with an explanation :
Thu Mar 18 11:00:19 2021
It prints the standard time equivalent to asctime() method.
Let’s Have a look at asctime() method:
Thu Mar 18 11:01:02 2021
Let’s move to another example where we will pass seconds as a parameter to ctime() method.
Mon Mar 15 14:44:25 2021
Here is another example where we pass a parameter to ctime() method.
Thu Jan 1 05:46:40 1970