Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
time.time not returning current epoch time?

In python time.time() returns the time in seconds since the epoch as a floating point number, but it seems the number is a bit short. If I run in JavaScript new Date().valueOf() I get 13 digits in length.

But if I run python time.time() I get a float with 10 digits and 6 after the decimal. Is time.time() not the correct method to use to get the same 13 digits as JavaScripts new Date().valueOf() method which says:

The valueOf() method returns the primitive value of a Date object as a number data type, the number of milliseconds since midnight 01 January, 1970 UTC.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The "correct" value of the number of seconds elapsed since 1/1/70 is the 10 digit number returned by Python.

new Date().valueOf()

Returns the value in milliseconds. If you want to get the number of seconds elapsed since 1/1/70, you need: new Date().valueOf() / 1000;

new Date().valueOf() / 1000
# 1641855239.355

Math.round(new Date().valueOf() / 1000);
# 1641855239

time.time()

Python returns the number of seconds elapsed since 1/1/70 and adds precision after the decimal point.

>>> import time
>>> time.time()
1641855239.3550372
>>> 
>>> round(time.time())
1641855239
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda