sendou.ink/app/components/RelativeTime.tsx
2026-08-05 15:36:31 +03:00

25 lines
478 B
TypeScript

import type * as React from "react";
import { useDateTimeFormat } from "~/hooks/intl/useDateTimeFormat";
export function RelativeTime({
children,
timestamp,
}: {
children: React.ReactNode;
timestamp: number;
}) {
const { formatter } = useDateTimeFormat({
hour: "numeric",
minute: "numeric",
day: "numeric",
month: "numeric",
timeZoneName: "short",
});
return (
<abbr title={formatter.format(new Date(timestamp)) ?? undefined}>
{children}
</abbr>
);
}