Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!