From the Art+Logic archive · written in 2013. The tools may have moved on; the thinking still holds.
Jon Hocking recently released a simple category on NSDate that generates relative timestamps such as “3 hours ago” or “2 days ago” from an NSDate instance.
I’ve put together an example project to demo how the code works at stevenhuey/PrettyDates. It makes use of CocoaPods to manage dependencies so make sure to use the .xcworkspace file and run:
pod install
before trying to build and run the app.
When you save yourself some time generating some nice relative timestamps in your next app make sure give @jonhocking a mention on Twitter.
Some problems are easier to explain in writing. Send us a few lines about what you're working on, and we'll reply within one business day. Helpful to include: