首页 > 移动平台 > 详细

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

时间:2014-06-22 22:38:18      阅读:377      评论:0      收藏:0      [点我收藏+]

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) 获取当前年、月、日等信息

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!