Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 1.17 KB

README.md

File metadata and controls

36 lines (24 loc) · 1.17 KB

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