开发者

Date Picker format problems

开发者 https://www.devze.com 2023-03-22 07:03 出处:网络
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:3

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消