Why the Formula Is Multiplication by 1,000
Since "milli-" means one-thousandth, a millisecond is 1/1,000 of a second. Turning that around, there are 1,000 milliseconds in every second. So to go from seconds to milliseconds, you multiply by 1,000. To go the other way, you divide.
Real-World Scenarios
Setting a JavaScript timeout: You want a function to fire after 2.5 seconds. That's 2.5 × 1,000 = 2,500 ms. You'd write setTimeout(fn, 2500).
Debouncing a search input: A common debounce delay is 0.3 seconds, which is 300 ms — short enough to feel responsive, long enough to avoid firing on every keystroke.
Configuring an API timeout: Your HTTP client has a timeout setting in milliseconds. If you want it to fail after 30 seconds, that's 30,000 ms.
CSS animations: An animation-duration of 0.4 seconds is 400 ms. Useful to know when you're cross-referencing CSS with JavaScript animation logic.
Time Unit Reference
- 1 second = 1,000 ms
- 1 minute = 60,000 ms
- 1 hour = 3,600,000 ms
- 1 day = 86,400,000 ms
Leave a Comment
We'd love to hear from you