Created
November 15, 2013 10:03
-
-
Save sag333ar/7481995 to your computer and use it in GitHub Desktop.
Get current Date mid-night time = 15-Feb-2013 00:00:00 So, You will get date with time 00:00:00 always.
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*) currentDate_midnightTime { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDate *now = [NSDate date]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:now]; | |
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 *fromDate = [cal dateFromComponents:comp]; | |
return fromDate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment