I'm currently doing this:
NSDateFormater *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateStyle:NSDateFormatterMediumStyle];
[dateFormat setTimeStyle:NSDateFormatterShortStyle];
[dateFormat setDoesRelativeDateFormatting:YES];
...
label.text = [dateFormat stringFromDate:thedate];
And this is producing:
Today, 1:00 PM
Yesterday, 1:00 PM
Oct 5, 2012, 1:00 PM
Oct 5, 2013, 1:00 PM
What I want is this:
1:00 PM
Yesterday
Oct 5
Oct 5 2013
Showing current year is OK (3rd line). At the very least the time should show only if it's today. On the iPhone the recent calls list does this. I need to do this because I have very little space for the date.
(Something like isEqualToString@"Today" will not work - This only works for English)
What's the easiest way to do this?
You'll have to write your own formatters to deal with this.
Have a look at https://github.com/mattt/FormatterKit to see how you could go about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With