0

JS how to use the new Date() as setInterval()?

Not exactly sure if it’s new Date(), but I know it’s something like that ... new Date(), or setDate(). I’ve seen people recommending using the new Date, (or set date if that’s the right one) instead of setInterval(). They say setInterval and interval aren’t stable... So how would I use the date object to set Interval, still using milliseconds?

17th Mar 2020, 6:28 AM
Ginfio
Ginfio - avatar
7 RĂ©ponses
+ 6
//Here is sololearn course on date object but i am not sure what you are concerned about setInterval() https://www.sololearn.com/learn/JavaScript/1244/
17th Mar 2020, 6:31 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 4
Ginfio Oh you wanted to find intervals between 2 times ,
17th Mar 2020, 7:06 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 3
Ginfio There is no function like setDate() and new date does not do work you mentioned , maybe it's is setTimeout() and can you please explain your problems more clearly
17th Mar 2020, 6:58 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
https://code.sololearn.com/WucfuigE2Z58/?ref=app Sudarshan Rai 👑 , I’m not comcerned about it. What i was thinking was like... In this code, I saw that with the setInterval() method, it wasn’t counting 1000 milsec in 1 second. The milliseconds are way behind than where they should be at. So, i mentioned that problem one time and someone mentioned to me about using setDate() instead of interval. .
17th Mar 2020, 6:36 AM
Ginfio
Ginfio - avatar
+ 1
Sudarshan Rai 👑 ahh, now i know what it is. If you would, look at the first answer on this thread (stackoverflow), that was what i was thinking about. it’s new Date() btw. https://stackoverflow.com/questions/1360818/how-to-measure-the-milliseconds-between-mousedown-and-mouseup
17th Mar 2020, 7:03 AM
Ginfio
Ginfio - avatar