title: How to set specific time & minutes to datepicker?
body: <p>I want to set specific time according to current time &amp; datepicker time.</p>
  
  <p>Like if user selects 3:01PM it goes directly to 3:30PM, 
  3:20PM then 3:45PM,
  3:35Pm then 4:00PM.
  if 5:00PM then 5:15pm.</p>
  
  <p>So user will be given options for time according to 3:00,3:15,3:30,3:45,4:00 and so on...</p>
  
  <p>I have achieved this &amp; when i go to 6:01Pm or any time in future than it works fine except i cant switch back to 5:01Pm (while current time is 3:00pm)</p>
  
  <p>Any solution or possibility for it problem?</p>
  
  <p>Try this below code.</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      [self.datePicker addTarget:self action:@selector(datechanged) forControlEvents:UIControlEventValueChanged];
  
  }
  
  
  
   NSDate *date = [self.datePicker date];
  
      NSCalendar *calendar = [NSCalendar currentCalendar];
      NSDateComponents *components = [calendar components:(NSMinuteCalendarUnit | NSHourCalendarUnit |NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:date];
      NSInteger minute = [components minute];
      NSInteger hour = [components hour];
  
  if ([components minute] == 0)
      {
  
          [components setMinute:15];
      }
      else
      {
          NSInteger result =  (minute / 15);
  
          if (result == 0)
          {
              [components setMinute:30];
          }
          else if(result == 2  || result == 1)
          {
              [components setMinute:45];
          }
          else if (result == 3)
          {
              [components setMinute:60];
          }
      }
  
  
      NSDate *newDate = [calendar dateFromComponents: components];
  
      [self.datePicker setMinimumDate:newDate];
      [self.datePicker reloadInputViews];
  </code></pre>