Skip to content

kyleclegg/NSDate-SmartTimeAgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NSDate-SmartTimeAgo

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.

Format

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

Installation

Add NSDate+SmartTimeAgo.{h,m} to your project.

Usage

  • #import "NSDate+SmartTimeAgo.h"
  • self.myLabel.text = [someObject.date smartTimeAgo];

Related

Contact

@kyle_clegg

About

Smartly display how long ago an event occurred in Objective-C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published