我想要当前日期中的某一天的数字。例如
if entry_date = August 22, 2011
due_on = "Due on 22nd"
我知道获取后缀的逻辑,但如何从当前日期获取日期值。
最佳答案
您可以按如下方式获取当前日期的日期:
NSDate * mCurrentDate = [NSDate date];
NSCalendar * calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents * weekdayComponents = [calendar components:NSDayCalendarUnit fromDate: mCurrentDate];
_day = [weekdayComponents day];
这将为您提供当前日期的日部分。
关于iphone - 如何从日期格式中获取整数天?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7304041/