What is the difference between javascript and python timestamp?

I have this javascript code:

(new Date()).getTime()

      

And this python code:

time.time()

      

The first one returns something like 1410072754803 , but python returns something like 1410077369.27 . I need python to return the same format as javascript. How can I get it?

PS: if i use

time.time() * 1000

      

it returns:

1.41007799536e+12

      

+3


source to share


1 answer


One returns milliseconds and the other returns seconds in float.

The python equivalent of javascript timestamp would be.



jts = int(time.time()*1000)

      

+2


source







All Articles