Creates a nice string that shows the time since the passed in date

Version
  • 1.0.0

Example

const date = new Date(Date.now() - 60 * 60 * 1000); // 1 hour ago
formatElapse(date); // Returns: "60 minutes ago"

const yesterdayDate = new Date(Date.now() - 24 * 60 * 60 * 1000); // Yesterday
formatElapse(yesterdayDate); // Returns: "Yesterday at HH:MM" (e.g., "Yesterday at 15:30")

const oldDate = new Date("2023-01-01");
formatElapse(oldDate); // Returns: false (for dates older than yesterday)