Created
November 15, 2013 10:04
-
-
Save sag333ar/7482009 to your computer and use it in GitHub Desktop.
Current date - 24 hours = Today 5 PM - 24 hours = Yesterdays 5 PM
This file contains 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
- (NSDate*)remove24HoursToDate:(NSDate*)date { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:date]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month; | |
comp.year = comp.year; | |
comp.day = comp.day; | |
[comp setHour:0]; | |
[comp setMinute:0]; | |
[comp setSecond:0]; | |
NSDate *modifiedDate = [cal dateFromComponents:comp]; | |
return modifiedDate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment