Get first day in a month from NSCalendar

前端 未结 6 1375
醉话见心
醉话见心 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:56

    You want [NSCalender dateFromComponents:] instead:

    NSDate *dayOneInCurrentMonth = [gregorian dateFromComponents:components];
    

提交回复
热议问题