How to show only week and time in DatePickerView?

40 Views Asked by At

In my application, i want to raise the notification using selected day and time, not with date.So i have to show the day and time only in DatePickerView. Would you please help me in this problem. Thanks in advance.

1

There are 1 best solutions below

0
makaron On

You should use NSDateFormatter for this purpose.

For example:

NSDate *now = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// e.g. "Tue 16:53"
[dateFormatter setDateFormat:@"EEEE HH:mm"];

NSString *szDate = [dateFormatter stringFromDate:now];
[dateFormatter release];
NSLog(@"Date formatted: %@", szDate);

(remove release if ARC is enabled);

And btw, the questions of this kind were asked million times around stackoverflow