码迷,mamicode.com
首页 > 其他好文 > 详细

在日期选择轮中选择的时间转换成年龄

时间:2015-12-04 20:44:24      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

if (sender.tag == TAG_BUTTON_SUMMIT) {
        NSTimeInterval dateDiff = [[dataPicker date] timeIntervalSinceNow];
        int age= fabs(trunc(dateDiff / (60 * 60 * 24)) / 365);
        ageLabel.text = [NSString stringWithFormat:@"%d", age];
        NSDate *date = [dataPicker date];
        //    限定格式
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyyMMdd"];
        [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
       
        NSString *strDate = [formatter stringFromDate:date];
        NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$%@", strDate);
       
        [_userDic setObject:strDate forKey:USERAGE];
        NSDictionary *user = [NSDictionary dictionaryWithDictionary:_userDic];
        [_dataHandle saveLocalData:USERINFO value:user];
    }

在日期选择轮中选择的时间转换成年龄

标签:

原文地址:http://www.cnblogs.com/tian-sun/p/5019968.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!