Python time time() Method


Description

Python time time() returns the timestamp of the current time (the number of floating-point seconds elapsed since the 1970 epoch).

Syntax

time() method syntax:

time.time()

Parameters

  • NA。

Return Value

Returns the timestamp of the current time (the number of floating-point seconds elapsed since the 1970 epoch).

Example

The following example demonstrates the usage of the time() function:

#!/usr/bin/python
import time

print "time.time(): %f " %  time.time()
print time.localtime( time.time() )
print time.asctime( time.localtime(time.time()) )

The output of the above example is:

time.time(): 1234892919.655932
(2009, 2, 17, 10, 48, 39, 1, 48, 0)
Tue Feb 17 10:48:39 2009
Other Extensions