Date Picker format problems
How do i solve the problem where i g开发者_StackOverflowot 2011-07-21 15:55:01 +0000 , but the timing is off by 4 hr, how do i remove the +0000? And I want the format to be Eg. Friday 12 June 2011 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];
}
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEEE dd MMMM yyyy h:mm a"];
NSString *words = [formatter stringFromDate:choise];
Here date formatter guide.
精彩评论