Is there an easy way with NSDateFormatter to get the dates Today, Tomorrow, Friday?

I am working on setting up NSDateFormatter to explain the date, and I need something short but more intuitive than 07/15/10. I think I saw some formats that would simply say "Today" or "Tomorrow" or the day of the week for subsequent days of the same week. Is there an easy way approved by apples to get this type of date?

Thanks.

+6
objective-c iphone cocoa-touch
source share
2 answers

If you configure iOS 4 or later, you can call [yourFormatter setDoesRelativeDateFormatting:YES] . Otherwise, you will most likely need a separate subclass. As for the days of the week, what jer said.

+12
source share

Make sure you set your language correctly using NSDateFormatter and then ask for weekdaySymbols . This will return an array with the days of the week in the locale you specify.

+1
source share

All Articles