Get timer time from UIDatePicker?

How do you get the time entered using UIDatePicker?

I have a button to click on and I have an IBAction, and what code will receive the data for you?

I would also like to see the time entered on the timer instead of starting the timer.

Oh yes, and Date Picker is a timer, not a date.

+4
source share
4 answers

Do you have a UIDatePicker with the datePickerMode parameter set to UIDatePickerModeCountDownTimer?

To get the currently selected value, use:

NSTimeInterval duration = datePickerView.countDownDuration; int hours = (int)(duration/3600.0f); int minutes = ((int)duration - (hours * 3600))/60; 
+10
source

Maybe this will help? UIDatePicker as a timer (video on vimeo)

0
source
 let t = datePicker.countDownDuration let date = NSDate(timeIntervalSinceReferenceDate: t) let calendar = NSCalendar(identifier: NSGregorianCalendar)! calendar.timeZone = NSTimeZone(forSecondsFromGMT: 0) var components = calendar.components(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, fromDate: date) var hour = components.hour var minute = components.minute return String(format: "%02d:%02d", hour, minute) 
0
source

you can use the above code snippets using NSDate will result in today's date and current time ...

NSDate * dmd = [NSDate date];

  NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"yyyy-MM-dd"]; NSString *dateString = [dateFormatter stringFromDate:dmd]; NSArray *temp=[dateString componentsSeparatedByString:@""]; NSLog(@"%@",[temp objectAtIndex:1]); 
-1
source

All Articles