Humanize Duration - Convert Time to Human-Readable Format
Transform time durations and differences into easy-to-read formats like “2 hours 5 minutes” or “3 days ago”. Perfect for user interfaces, reports, and making time data more accessible.
What is Duration Humanization?
Duration humanization converts raw time values (seconds, minutes, milliseconds) into natural language that’s easy for humans to understand. Instead of showing “7200 seconds”, it displays “2 hours”.
Key Features
- ✅ Multiple input formats - Seconds, milliseconds, minutes, hours
- ✅ Flexible output - Various human-readable formats
- ✅ Relative time - “ago” and “from now” calculations
- ✅ Customizable precision - Show seconds, minutes, or broader units
- ✅ Real-time conversion - Instant results as you type
- ✅ Copy functionality - Easy copying of formatted results
Common Use Cases
User Interface Development
- Activity feeds - “Posted 5 minutes ago”
- File timestamps - “Modified 2 days ago”
- Progress indicators - “Estimated 10 minutes remaining”
- Session timeouts - “Session expires in 15 minutes”
Reporting and Analytics
- Performance metrics - “Average response time: 250ms”
- Uptime reports - “System uptime: 45 days 6 hours”
- Data processing - “Processing completed in 3 minutes 42 seconds”
- Log analysis - Human-readable time differences in logs
Content Management
- Blog posts - “Published 2 weeks ago”
- Comments - “Comment added 1 hour ago”
- Updates - “Last updated 3 days ago”
- Scheduling - “Event starts in 2 hours 30 minutes”
Output Format Examples
Precise Format
2 hours 15 minutes 30 seconds1 day 5 hours 20 minutes45 minutes 12 seconds3 weeks 2 days 8 hours
Approximate Format
about 2 hoursroughly 1 dayaround 45 minutesnearly 3 weeks
Relative Format
5 minutes agoin 2 hours3 days from nowlast week
Short Format
2h 15m1d 5h45m3w 2d
Best Practices
User Experience
- Context matters - Use appropriate precision for the context
- Consistency - Use the same format throughout your application
- Localization - Consider translating for international users
- Accessibility - Provide full timestamps for screen readers
Performance
- Cache calculations - Store humanized values when possible
- Update intervals - Refresh “ago” times periodically
- Batch processing - Process multiple durations together
- Precision limits - Don’t show unnecessary precision
Display Guidelines
- Recent times - Show precise values (5 minutes ago)
- Older times - Use broader units (2 weeks ago)
- Future times - Clear indication (in 3 hours)
- Very short durations - Consider showing “just now”
Common Time Units
Standard Units
- Millisecond - 1/1000 of a second
- Second - Base unit of time
- Minute - 60 seconds
- Hour - 60 minutes (3,600 seconds)
- Day - 24 hours (86,400 seconds)
- Week - 7 days (604,800 seconds)
- Month - ~30.44 days (2,629,746 seconds)
- Year - 365.25 days (31,557,600 seconds)
Precision Considerations
- Sub-second - For performance measurements
- Minutes - For short-term activities
- Hours - For daily activities
- Days - For recent history
- Weeks/Months - For longer periods
- Years - For historical data