Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Localized Hours Range String
NSDateComponents *comps = [[NSDateComponents alloc] init];
comps.year = 2015;
comps.month = 5; = 12;
comps.hour = 21;
NSDate *startDate = [[NSCalendar currentCalendar] dateFromComponents:comps]; = 13;
comps.hour = 0;
NSDate *endDate = [[NSCalendar currentCalendar] dateFromComponents:comps];
NSDateIntervalFormatter *formatter = [[NSDateIntervalFormatter alloc] init];
formatter.timeZone = [NSTimeZone localTimeZone];
formatter.dateStyle = NSDateFormatterNoStyle;
formatter.timeStyle = NSDateFormatterShortStyle;
NSString *string = [formatter stringFromDate:startDate toDate:endDate];
NSLog(@"%@", string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.