Reputation: 3015
Is there any way to show only week day with Date as: MON 03-JUL
in UIDatePicker
in iPhone.
Please help.
Upvotes: 1
Views: 3646
Reputation: 8855
No, as far as I know there is no way to set a custom date format in UIDatePicker. Anyways, it wouldn't make much sense to display only the weekdays in a date picker, because you would end up with multiple entries for each weekday:
If you only want the user to pick a weekday (Mon-Sun), you could simply use a UIPickerView. And make sure you don't hard-code the weekday names, but rather use - (NSArray *)weekdaySymbols
on NSDateFormatter
. This will take the user's locale into account and returns an array of weekday names as strings:
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
NSArray* weekdays = [dateFormatter weekdaySymbols];
// will return Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday (en_US locale)
Alternatively you can use shortWeekdaySymbols
:
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
NSArray* weekdays = [dateFormatter shortWeekdaySymbols];
// will return Sun,Mon,Tue,Wed,Thu,Fri,Sat (en_US locale)
Upvotes: 5