开发者

How to get month & year from NSDate?

开发者 https://www.devze.com 2022-12-14 13:46 出处:网络
Is there any way/ method to seperate month & year form NSDate? I just need to display current month & ye开发者_StackOverflow中文版ar?

Is there any way/ method to seperate month & year form NSDate?

I just need to display current month & ye开发者_StackOverflow中文版ar? Any Example?


NSDate *date = [NSDate date];
NSDateComponents *dateComponents = [calendar components:unitFlags fromDate:date];
NSInteger year = [dateComponents year];
NSInteger month = [dateComponents month];
[calendar release];

cheers endo


This could be done by using NSDateComponents

0

精彩评论

暂无评论...
验证码 换一张
取 消