Textual display of millisecond durations and in several languages.
Tims is not a converter and is not intended to be precise. It only converts milliseconds to a textual duration description. If you need to manage dates accurately, use dayjs instead.
- typescript typings included
- no dependency
- optimized and light code
npm install tims@latest
// Typescript or ESModules
import tims from "tims"
// CommonJS
const tims = require("tims")
Use for display uptime in Spanish
const startedAt = new Date()
function displayUptime() {
const uptimeText = tims.since(startedAt, { locale: "es" })
console.log(uptimeText)
}
Get the sentence of time past since given moment
Get the sentence of time between given moments
Get the sentence of given duration
interface Options {
format?: "day" | "year" | "month" | "hour" | "minute" | "second" | "ms"
locale?: "fr" | "es" | "en"
full?: boolean
}