Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

359 B
Raw Blame
import dayjs from 'dayjs';

import { normalizeDayjsLocale } from '@/utils/dayjsLocale';

export const formatNotificationRelativeTime = (
  createdAt: Date | string,
  locale?: string,
): string => {
  const date = dayjs(createdAt);

  if (!date.isValid()) return '';

  return locale ? date.locale(normalizeDayjsLocale(locale)).fromNow() : date.fromNow();
};