Skip to main content
Home

latest

Utility functions

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.0.1)
function timeAgo
timeAgo(
dateInMillis: number,
lang?: Languages,
): string

Returns a string (e.g '8 days ago') representing the time difference between the current time and the provided date in milliseconds.

Examples

Example 1

timeAgo(new Date().getTime() - 10000);

Parameters

dateInMillis: number

The date in milliseconds since the epoch.

optional
lang: Languages = defaultLang

The language to use. Defaults to 'en' (English).

Return Type

The time difference as a string.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@tuanis/utils

Import symbol

import { timeAgo } from "@tuanis/utils";
or

Import directly with a jsr specifier

import { timeAgo } from "jsr:@tuanis/utils";

Add Package

pnpm i jsr:@tuanis/utils
or (using pnpm 10.8 or older)
pnpm dlx jsr add @tuanis/utils

Import symbol

import { timeAgo } from "@tuanis/utils";

Add Package

yarn add jsr:@tuanis/utils
or (using Yarn 4.8 or older)
yarn dlx jsr add @tuanis/utils

Import symbol

import { timeAgo } from "@tuanis/utils";

Add Package

vlt install jsr:@tuanis/utils

Import symbol

import { timeAgo } from "@tuanis/utils";

Add Package

npx jsr add @tuanis/utils

Import symbol

import { timeAgo } from "@tuanis/utils";

Add Package

bunx jsr add @tuanis/utils

Import symbol

import { timeAgo } from "@tuanis/utils";