CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Dec 2014 |
Maintained by Nikil Viswanathan.
I was really surprised that I couldn't find an iOS date formatter which implemented the Facebook style "Time Ago" format so I whipped one up myself. I reverse engineered the Facebook format, so this should be pretty accurate. Feel free to use it in your projects / improve it.
Hope you enjoy :)
If you have any questions feel free to contact me here: www.nikilster.com/about.html
< 1 minute = "Just now"
< 1 hour = "x minutes ago"
Today = "x hours ago"
Yesterday = "Yesterday at 1:28pm"
< Last 7 days = "Friday at 1:48am"
< Last 30 days = "March 30 at 1:14 pm"
< 1 year = "September 15"
Anything else = "September 9, 2011"
In the files that you want to use this functionality in,itType:
#import "NSDate+NVTimeAgo.h"
somewhere near the top of your file.
Use the date formatter on a date by calling:
[date formattedAsTimeAgo]
where date is an (NSDate *) and represents a date IN THE PAST (relative to now).
If you have a mysql datetime string and you want to convert it to the time ago format, do:
NSString *mysqlDatetime = <Get from the database>
NSString *timeAgoFormattedDate = [NSDate mysqlDatetimeFormattedAsTimeAgo:mysqlDatetime];`
Nikil Viswanathan on 4/18/2013
You can contact me on: www.nikilster.com
Thanks to dellinger for making it into a CocoaPod.