Code Logo

Relative Time Formatter

Published at14 Jun 2026
Easy 36 views
Like42

Create a timestamp formatter that converts a date into a relative description like "5 minutes ago" or "2 days ago".

Given a past timestamp, compute how long ago it occurred and format it as a friendly relative string.

Implement the logic for seconds, minutes, hours, days, weeks, months, and years. Update the display automatically over time.

Handle future dates gracefully.

Test with various time differences.

Algorithm Flow

Recommendation Algorithm Flow for Relative Time Formatter

Best Answers

Solutions Coming Soon

Verified best solutions for this Challenge are still being analyzed and will be available soon.