如何从日期格式中取整数天?

Dev*_*per 2 iphone objective-c

我想要一个当前日期的数字日期.例如

if entry_date = August 22, 2011 
due_on = "Due on 22nd"
Run Code Online (Sandbox Code Playgroud)

我知道获取后缀的逻辑,但是如何从我当前的日期获得日期值.

iCo*_*777 6

您可以从当前日期获得如下日期:

NSDate * mCurrentDate = [NSDate date];

NSCalendar * calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents * weekdayComponents = [calendar components:NSDayCalendarUnit fromDate: mCurrentDate];

    _day    = [weekdayComponents day];
Run Code Online (Sandbox Code Playgroud)

这将为您提供当前日期的日期部分.

希望这会帮助你...