Get first day in a month from NSCalendar

前端 未结 6 1321
醉话见心
醉话见心 2021-01-12 05:24

I have this subset of a method that needs to get day one of the current month.

NSDate *today = [NSDate date];  // returns correctly 28 february 2013
NSCalend         


        
6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-12 05:38

    NSDate *startDate = nil;
    [[NSCalendar currentCalendar] rangeOfUnit:NSCalendarUnitMonth startDate:&startDate interval:NULL forDate:date];
    
    return startDate;
    

提交回复
热议问题