Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

456 B
Raw Blame
import { getDiffInDaysFromNow } from '../../../utils/helpers';

export function formatTimestamp(sentAt: Date) {
  const now = new Date(sentAt);
  if (Number.isNaN(now)) return '';

  const diffInDays = getDiffInDaysFromNow(sentAt);

  if (diffInDays >= 1) {
    const localeDate = now.toLocaleDateString('en-US', {
      dateStyle: 'medium',
    });
    return `${localeDate} at ${now.toLocaleTimeString()}`;
  }

  return `${now.toLocaleTimeString()}`;
}