A category that simplifies displaying strings like "4 minutes ago" or "Uploaded 2 weeks ago." Inspired by the excellent DateTools, SmartTimeAgo handles the logic of determining how long ago an event occurred and smartly returns the duration in the appropriate time unit.
The default format is simply "X [time unit] ago" and can be easily modified.
Date | String |
---|---|
In future | 0 seconds ago |
< 1 minute | 30 seconds ago |
< 1 hour | 30 minutes ago |
< 24 hours | 6 hours ago |
< 30 days | 3 weeks ago |
< 1 year | 6 months ago |
else | 6 years ago |
Add NSDate+SmartTimeAgo.{h,m}
to your project.
#import "NSDate+SmartTimeAgo.h"
self.myLabel.text = [someObject.date smartTimeAgo];
- DateTools - Best NSDate category out there
- NSDate-Time-Ago - Facebook style time ago