码迷,mamicode.com
首页 > 移动开发 > 详细

iOS Dev (55) 获取当前年、月、日等信息

时间:2014-06-22 22:39:27      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:style   blog   code   http   tar   ext   

iOS Dev (55) 获取当前年、月、日等信息

-

NSDate *now = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSUInteger unitFlags = 
    NSYearCalendarUnit |
    NSMonthCalendarUnit |
    NSDayCalendarUnit |
    NSHourCalendarUnit |
    NSMinuteCalendarUnit |
    NSSecondCalendarUnit;
NSDateComponents *dateComponent = [calendar components:unitFlags fromDate:now];

int year = [dateComponent year];
int month = [dateComponent month];
int day = [dateComponent day];
int hour = [dateComponent hour];
int minute = [dateComponent minute];
int second = [dateComponent second];

Reference

  • http://www.cnblogs.com/programmer-blog/p/3265110.html

iOS Dev (55) 获取当前年、月、日等信息,布布扣,bubuko.com

iOS Dev (55) 获取当前年、月、日等信息

标签:style   blog   code   http   tar   ext   

原文地址:http://blog.csdn.net/prevention/article/details/32324633

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