を使用NSCalendar
して、日付の月、日、および年のコンポーネントを取得し、それらを操作して、再組み立てすることができます。ここにいくつかのサンプルコードがあります。
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit ) fromDate:date];
[otherDateComponents setYear:[dateComponents year]];
[otherDateComponents setMonth:[dateComponents month]];
[otherDateComponents setDay:[dateComponents day]];
NSDate *newDate = [calendar dateFromComponents:otherDateComponents];
現在のカレンダーはロケール固有であるため、返される値はすべてのデバイスで同じではないことに注意してください。目的に応じて特定のカレンダーを指定することをお勧めします。NSGregorianCalendar
西部で最も頻繁に使用されるものです。