2012-02-01 85 views
0

,请参见下面的代码如何日期组件添加到NSDate的有时间格式

 NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; 
     [outputFormatter setDateFormat:@"h:mm a"]; 
     NSDate *dat=pickerView.date; 
     NSString *timerString=[outputFormatter stringFromDate:dat]; 

     [startTimer setTitle:timerString forState:UIControlStateNormal]; 
     timeString=timerString; 
     [self updatePrayerTimigs]; 
     //dat=[NSDate dateWithTimeIntervalSinceNow:20]; 
     UILocalNotification *local=[[[UILocalNotification alloc]init] autorelease]; 
     UIApplication *app=[UIApplication sharedApplication]; 
     if(local){ 
      local.fireDate=dat; 
      local.timeZone=[NSTimeZone defaultTimeZone]; 
      //local.repeatInterval=0; 
      [email protected]"Hello"; 
      local.repeatInterval=NSMinuteCalendarUnit; 
      [app scheduleLocalNotification:local]; 
      [app presentLocalNotificationNow:local]; 
     }// end of the if 

我只选择时间(小时,分)从的UIDatePicker,所以我可以解雇的通知,所以我决定将当前的日期上面的NSDate与选择的UIDatePicker,请帮助我如何能做到这一点

+0

请更详细的关于你的问题。你想在日期选择器中添加日期吗? – 2012-02-01 10:42:46

+0

我想设置从UIDatePicker(它只包含时间)中选择的时间的本地通知,但不幸的是,我不能只设置本地通知?我需要在那段时间添加日期 – Ali 2012-02-01 10:46:08

回答

0

试试这个格式化日期

NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; 

[outputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];