Omri Perl
Omri Perl

Reputation: 131

Is it possible for a date picker to present year/month/day + day name?

Is it possible to add the day name to the date picker? For example to dials will show:

(sunday)3 | 11 | 2012

is it even possible? Thanks!

Upvotes: 5

Views: 3352

Answers (4)

iDhaval
iDhaval

Reputation: 7844

I think you can not DayName(eg. Sunday) with Year-Month-Day until you not make it totally custom but you can get the day with date by following code may be It will help you.

Bind following two IBOutlet in Xib.

and bind method -(IBAction)GetDateWithDay with DatePicker with ValueChange attribut

in .h file

IBOutlet UIDatePicker* datePicker;
IBOutlet UILabel* lblDate;

in .m file

-(IBAction)GetDateWithDay
{

     NSDate* dt = datePicker.date;
     NSDateFormatter* df = [[[NSDateFormatter alloc]init]autorelease];
     [df setDateFormat:@"yyyy-MM-dd"];

     NSCalendar *calendar = [NSCalendar currentCalendar];
     NSInteger units = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit;
     NSDateComponents *components = [calendar components:units fromDate:dt];
     NSInteger year = [components year];
     NSInteger day = [components day];

     NSDateFormatter *weekDay = [[[NSDateFormatter alloc] init] autorelease];
     [weekDay setDateFormat:@"EEEE"];

     NSDateFormatter *calMonth = [[[NSDateFormatter alloc] init] autorelease];
     [calMonth setDateFormat:@"MM"];

     lblDate.text = [NSString stringWithFormat:@"%@, %i-%@-%i",[weekDay stringFromDate:dt], day, [calMonth stringFromDate:dt], year];

}

Upvotes: 4

Ravi Kumar Karunanithi
Ravi Kumar Karunanithi

Reputation: 2218

You can use the option DD. For Example.

$.datepicker.formatDate('DD', new Date(2007, 1 - 1, 26));

Hope this will help you. UI/Datepicker/formatDate

Upvotes: -3

Prasad G
Prasad G

Reputation: 6718

Read this document It will be helpful to you

Upvotes: 0

Related Questions