Skip to content

Instantly share code, notes, and snippets.

@ariok
Created November 29, 2013 17:39
Show Gist options
  • Save ariok/7709292 to your computer and use it in GitHub Desktop.
Save ariok/7709292 to your computer and use it in GitHub Desktop.
Reset the time of an NSDate to 00:00:00 (Note: GMT+1 is 23:00:00 etc.. )
// Reset the time information to 00:00:00
- (NSDate*)resetTimeForDate:(NSDate*)date{
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit
fromDate:date];
[components setTimeZone:[NSTimeZone defaultTimeZone]];
NSDate *clearedDate = [[NSCalendar currentCalendar] dateFromComponents:components];
return clearedDate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment