首页 > 其他 > 详细

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

时间:2015-12-04 20:44:06      阅读:118      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!