Latest web development tutorials

Python time time () method

description

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

grammar

time () method syntax:

time.time()

parameter

  • NA.

return value

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

Examples

The following example shows the time () function to use:

#!/usr/bin/python
import time

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

The above example output is:

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