iSara iSara - 3 months ago 9
Objective-C Question

How to set UIDatePicker's date's seconds value to 00?

How to always get seconds value "

00
" for
UIDatePicker
's date?

Now I am getting value like this format
5:30:45
, I need to get this format of time
5:30:00
.

How to achieve this?

Answer
NSDate *currentDate = [datePicker date];    
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"ss"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
NSString *Str_Seccond=[dateFormatter stringFromDate:currentDate];

In Str_Seccond string you can get the seconds in string format.