What is epoch time in python? Also can someone please explain the following code:
time.ctime(time.time())
What is epoch time in python? Also can someone please explain the following code:
time.ctime(time.time())
As stated for time.time() method:
This method returns the time as a floating point number expressed in seconds since the epoch, in UTC.
As stated for time.ctime():
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().
Thus the output of the following code would be something like this:
print "time.ctime() : %s" % time.ctime(time.time())
would be something like this:
time.ctime() : Tue Feb 17 10:00:18 2009
Epoch time is UNIX time, an integer value in seconds since 1.1.1970.
According to the doc :
The epoch is the point where the time starts. On January 1st of that year, at 0 hours, the “time since the epoch” is zero. For Unix, the epoch is 1970. To find out what the epoch is, look at gmtime(0).
And about time.ctime()
:
time.ctime([secs])
Convert 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. ctime(secs) is equivalent to asctime(localtime(secs)). Locale information is not used by ctime().