Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Check if the time difference is less than 1 second in moment

$
0
0

In my javascript project, I want to check if the time difference is less than 1 second. I use moment to get this difference. This is the function I have written to achieve it.

const withinOneSecond = (time) => {
  const currentTime = moment();
  return time + 1000 < currentTime;
};

But this doesn't work as expected. How can I check if the given time is within a second to the current time?


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>