2011-07-20 44 views
0

我如何解決問題,我得到2011-07-21 15:55:01 +0000,但時間是關閉4小時,我如何刪除+0000?我想要的格式是Eg。週五2011年6月12日1:30 PM日期選取器格式問題

-(IBAction)addButton:(id)sender 
{ 
    NSDate *choice = [datepick date]; 
    NSString *words = [[NSString alloc]initWithFormat:@"%@", choice]; 
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Date Chosen 
              message:words 
              delegate:nil 
              cancelButtonTitle:@"OK" 
              otherButtonTitles:nil]; 

    [alert show]; 
    [alert release]; 
    [words release]; 

    label.text = words; 
    textfield.text = words; 
} 

- (void)viewDidLoad 
{ 
    NSDate *now = [[NSDate alloc] init]; 
    [datepick setDate:now animated:YES]; 
    [now release]; 
    datepick.minimumDate = [NSDate date]; 
    [super viewDidLoad]; 
} 

回答

1
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 
[formatter setDateFormat:@"EEEE dd MMMM yyyy h:mm a"]; 
NSString *words = [formatter stringFromDate:choise]; 

Here日期格式指南。