// Assume that (NSDate *)date already exists.
NSCalendar* calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
unsigned int flags = NSYearCalendarUnit |
NSMonthCalendarUnit |
NSDayCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit;
NSDateComponents *components = [calendar components:flags fromDate:date];
[calendar release];
// Here, you can get information about (NSDate *)date
// by using methods year, month, day, hour, minute, and second of instance (NSCalendar *)components.
[components release];
参考:
【Cocoa】NSDateから日時の値を取得する
0 件のコメント:
コメントを投稿