Abbrev. (words) for "year", "month" and so on from Locale

71 views Asked by At

I try to print a time period with format like this : "2 years, 3 months, 15 days, 23 hours, 15 min and 35 sec". I want to use these date/time abbrev (words) for another purposes too ... Is it possible to get abbrev for "years", "months" and so on from Locale (regional), so the output be are more friendly with different regional setings ? Thank you in advance !

1

There are 1 answers

0
Ashok On

This NSDate+TimesAgo category provides localized strings in times ago format e.g. a moment ago, 5 seconds ago etc as given below

NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:0]
NSString *ago = [date timeAgo];
NSLog(@"Output is: \"%@\"", ago);
2011-11-12 17:19:25.608 Proj[0:0] Output is: "41 years ago"

5 You might need to edit it to achieve your purpose. Please check license clause.