Created
November 29, 2013 17:39
-
-
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.. )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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