We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e.g.
humanInterval(60 * 1000); // returns "one minute"
The text was updated successfully, but these errors were encountered:
I needed this too and so I copied @erfanium's code example into ChatGPT which provided this function:
function humanInterval(ms) { if (ms < 1000) return `${ms} milliseconds`; if (ms < 60000) return `${Math.round(ms / 1000)} seconds`; if (ms < 3600000) return `${Math.round(ms / 60000)} minutes`; if (ms < 86400000) return `${Math.round(ms / 3600000)} hours`; return `${Math.round(ms / 86400000)} days`; }
Which I then used to wrap this package, like so:
const _humanInterval = require('human-interval'); function humanInterval(input) { if (typeof input === "number") { let ms = input; if (ms < 1000) return `${ms} milliseconds`; if (ms < 60000) return `${Math.round(ms / 1000)} seconds`; if (ms < 3600000) return `${Math.round(ms / 60000)} minutes`; if (ms < 86400000) return `${Math.round(ms / 3600000)} hours`; return `${Math.round(ms / 86400000)} days`; } else { return _humanInterval(input) } }
This was a quick solution which worked well to realize the functionality.
Sorry, something went wrong.
https://github.com/EvanHahn/HumanizeDuration.js
No branches or pull requests
e.g.
The text was updated successfully, but these errors were encountered: