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

211
Views
Date getSeconds returns 0 when subtracting to another Date getSeconds
function returntime() {
  var start = new Date().getSeconds();
  var end = new Date().getSeconds();
  var totaltime = end - start;
  document.getElementById("Answer").innerHTML = totaltime;
}

The totaltime return 0 but when i put start or end it shows the output.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

There is no delay between both statements.

var start = new Date().getSeconds();
  var end = new Date().getSeconds();

See this image for debugger output

about 4 years ago · Juan Pablo Isaza Report

0

You ask for seconds. The code runs faster than a second. For example, you get 9 seconds at the start and 9 seconds in the end. If you ask for the milliseconds you will see that you will have a different result.

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!