Skip to content

Instantly share code, notes, and snippets.

@ZevEisenberg
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZevEisenberg/d29476094201e4076c03 to your computer and use it in GitHub Desktop.
Save ZevEisenberg/d29476094201e4076c03 to your computer and use it in GitHub Desktop.
Localized Hours Range String
NSDateComponents *comps = [[NSDateComponents alloc] init];
comps.year = 2015;
comps.month = 5;
comps.day = 12;
comps.hour = 21;
NSDate *startDate = [[NSCalendar currentCalendar] dateFromComponents:comps];
comps.day = 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