日期选择器(IOS开发)

时间:2014-10-23 00:07:30   收藏:0   阅读:323

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)onclick:(id)sender {
    NSDate *theDate = self.dataPicker.date;
    
    // descriptionWithLocale 方法返回本地时间
    // currentLocale 返回当前使用者信息
    NSLog(@"the date picked is: %@", [theDate descriptionWithLocale:[NSLocale currentLocale]]);
    
    // 设定格式化格式
    // dd和DD的区别
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    
    // 输出
    NSLog(@"the date formate is: %@",[dateFormatter stringFromDate:theDate]);
    self.label.text = [dateFormatter stringFromDate:theDate];
    
}
    

详见注释:关于dd和DD的区别就是,dd返回当前月份的第几天,而DD返回当年的第几天



原文:http://blog.csdn.net/liyakun1990/article/details/40383917

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!