+ (NSInteger) daysdifference:(NSString*)start end:(NSString*)end
{
//start = @"2013-01-26";
//end = @"2013-02-09";
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"yyyy/MM/dd"];
NSDate *startDate = [df dateFromString:start];
NSDate *endDate = [df dateFromString:end];
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSDayCalendarUnit
fromDate:startDate
toDate:endDate
options:0];
return components.day;
}
iOS get day difference by NSDateComponents
標籤: iOS 0 意見張貼者: kenywalker 於 下午6:17
iOS NSDateFormatter
標籤: iOS 0 意見First of all, you can use [NSDate date] to get current date, then NSDateFormatter to set the format you want. That's all.
NSDate *srcdate = [NSDate date];
NSDateFormatter *date = [[NSDateFormatter alloc] init];
date.dateFormat = @"yyyy/MM/dd";
NSString *datefrom = [NSString stringWithFormat:@"%@", [date stringFromDate:srcdate]];
yyyy yy MM(numeric) MMM(Jan, Feb...) MMMM(full Month) dd K(12) H(24) mm ss aa(AM/PM) EEE(Week) EEEE(Week Full)
張貼者: kenywalker 於 下午6:14
iOS jump to dedicated tab page
標籤: iOS 0 意見
self.tabBarController.selectedIndex = 1;
張貼者: kenywalker 於 下午6:09
訂閱:
意見 (Atom)
Diseño e iconos por N.Design Studio | A Blogger por Blog and Web
