- Published on
How to parse milliseconds into an object in JavaScript
- Authors
- Name
- Ashik Nesin
- @AshikNesin
When working with time, almost all the time we represent that in milliseconds. Though it does its job well. It's hard for us to easily recognise it.
Here is how to parse the milliseconds (in numbers) to a detailed representation of it in an object
Dependency
npm install parse-ms
Snippet
// Based on parse-ms's README example
import parseMilliseconds from 'parse-ms';
parseMilliseconds(9876543210)
/*
{
days:114,
hours:7,
minutes:29,
seconds:3
milliseconds:210,
microseconds:0,
nanoseconds:0,
}
*/
Happy parsing milliseconds!