Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am new to ios development.

I am making a custom datepicker using UIPickerView.

I have to show dates ranging from today to next 20 days & I am done with generating those dates & assigning them to an array.Those Dates have format: Oct 16,2013.

But my problem is I want to show Weekday(in 3 characters),Month & day i.e. Wed,Oct 16 on UIpickerView. And for one current week only Days are shown i.e today,tomorrow,Fri,Sat,Sun,Mon,Tue and for Next Week it would have Wed,Oct 23 and so on.

Thanks in advance! Any help would be greatly appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
228 views
Welcome To Ask or Share your Answers For Others

1 Answer

Assuming that you have a NSDate object called myDate for example, You need to format the dates using a date formater:

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"EEE, LLL d"];

NSString *myString = [dateFormat stringFromDate:myDate];

You can find the formatters and what they mean here:

NSDateFormatter formatting

To get today:

NSdate *today = [NSDate date];

Tomorrow:

NSDate *tomorrow = [NSDate dateWithTimeInterval:(24*60*60) sinceDate:[NSDate date]]

After tomorrow:

NSDate *afterTomorrow = [NSDate dateWithTimeInterval:(24*60*60) sinceDate:tomorrow]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...