Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python time time() method

Python time time() method


Description

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

Syntax

time() method syntax:



time.time()

Parameters

Return Value

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

Example

The following example shows how to use 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