Skip to content
العربية
Saudi and bilingual kit

TimeText

Dates and times in Riyadh time on a 12-hour clock (hourCycle="h23" on TimeText, formatDateTime or PercentProvider gives 24 hours: 15:05; agoForm="short" gives "5 min ago"): the time for today, a word for yesterday and tomorrow, the day for older dates. Hover, focus or tap shows the exact value. A time without a zone is read as UTC. kind="time" shows the clock only, for lists grouped by day; the tooltip has the full date and time. formatTimeOfDay shows a time of day such as opening hours. inSentence writes “today”, “yesterday” and “tomorrow” in lower case, for a time inside a sentence (“until tomorrow 3:45 PM”). formatDateTime takes the same option.

import { TimeText, formatDateTime, formatRelative } from "@percentsa/ui";

Examples

Open until

2 months ago

Sunday 27 September 2026, 3:45:12 PM

Code
export function TimeTextExample() {
  const lang = useLang();
  const t = useT();
  return (
    <Stack gap={2}>
      <TimeText value="2026-09-27T09:10:00Z" now={NOW} />
      <TimeText value="2026-09-26T18:30:00Z" now={NOW} />
      <TimeText value="2026-09-12T12:45:00Z" now={NOW} />
      <TimeText value="2025-03-02T08:00:00Z" now={NOW} />
      <TimeText value="2026-09-28" kind="date" now={NOW} />
      <TimeText value="2026-09-27T12:40:00Z" ago now={NOW} />
      <TimeText value="2026-09-26T18:30:00Z" kind="time" now={NOW} />
      <Text size="sm">{t("Open until", "مفتوح حتى")} <TimeText value="2026-09-28T09:10:00Z" inSentence now={NOW} /></Text>
      <Text size="sm" tone="muted">{formatRelative("2026-07-29T12:45:00Z", { lang, now: NOW })}</Text>
      <Text size="sm" tone="muted">{formatDateTime("2026-09-27 12:45:12", { lang, style: "full" })}</Text>
    </Stack>
  );
}
Code
export function TimeText24Example() {
  return (
    <Stack gap={2}>
      <TimeText value="2026-09-27T12:05:00Z" now={NOW} hourCycle="h23" />
      <TimeText value="2026-09-26T18:30:00Z" now={NOW} hourCycle="h23" />
      <TimeText value="2026-09-27T12:40:00Z" ago now={NOW} agoForm="short" />
    </Stack>
  );
}