f0rextasy

Time Ago

Component

About

A small text label that shows how long ago a timestamp happened (e.g. "5 MINS AGO") and re-renders itself every 30 seconds to stay current.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Time Ago to your project and fits it to your theme.

Code

How Time Ago is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { TimeAgo } from "@/components/ui/time-ago";

export default function TimeAgoDemo() {
  const now = Date.now();

  return (
    <div className="flex min-h-52 w-full items-center justify-center bg-background p-8">
      <div className="flex flex-col gap-3 rounded-lg border border-border bg-card p-6">
        <TimeAgo date={new Date(now - 1000 * 5)} live />
        <TimeAgo date={new Date(now - 1000 * 60 * 5)} live />
        <TimeAgo date={new Date(now - 1000 * 60 * 60 * 3)} live />
        <TimeAgo date={new Date(now - 1000 * 60 * 60 * 24 * 2)} live />
      </div>
    </div>
  );
}

More by f0rextasy

View all
  • Newsletter Signup Card

    Newsletter Signup Card

    1
  • Time Input

    Time Input

    1
  • User Profile Dossier

    User Profile Dossier

  • Clinic Booking Block

    Clinic Booking Block

  • Page About

    Page About

  • Empty State Card

    Empty State Card

  • Emoji Picker

    Emoji Picker

  • Running Order Timeline

    Running Order Timeline