native-duration
v0.2.1
Published
Calculate duration between two dates with zero dependencies (via Date object)
Downloads
13
Maintainers
Readme
native-duration
JavaScript / TypeScript library to Calculate duration between two dates with zero dependencies (via Date object).
Usage
import Duration from "native-duration";
const now = new Date();
console.log(Duration.of(10 ** 9).toString());
// 1w 4d 13h 46min 40s
Of course, you can easily use it in any website, without Node.js, thanks to UNPKG.
<div id="mil-secs"></div>
<script type="module">
import Duration from "https://unpkg.com/native-duration";
const now = new Date();
document.getElementById("mil-secs").innerText = Duration.of(
10 ** 9
).toString();
</script>
Installation
npm i native-duration
Or, install directly from GitHub main branch.
npm i patarapolw/native-duration