Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

John Baughman

macrumors regular
Original poster
Oct 27, 2003
100
0
Not sure if this is common knowledge, but searching the Internet on this subject turns up solutions using NSDateComponents which is fine. Here is a very quick and easy way I have found to do it with NSDateFormatter.

Code:
dateAtMidnightFormatter = [[NSDateFormatter alloc] init];
[dateAtMidnightFormatter setDateStyle:NSDateFormatterShortStyle];
[dateAtMidnightFormatter setTimeStyle:NSDateFormatterNoStyle];

NSDate *todayAtMidnight = [dateAtMidnightFormatt dateFromString:[dateAtMidnightFormatter stringFromDate:[NSDate date] ] ];

John
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.