× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Check if two NSDates are in the same day

Joe Masilotti
May 13, 2015
<p>If you are working with iOS 8 you can use <code>-isDate:inSameDayAsDate:</code>.</p> <p>From <code>NSCalendar.h</code>:</p> <pre><code>/* This API compares the Days of the given dates, reporting them equal if they are in the same Day. */ - (BOOL)isDate:(NSDate *)date1 inSameDayAsDate:(NSDate *)date2 NS_AVAILABLE(10_9, 8_0); </code></pre> <p>Note that for some reason this didn't make it to the official documentation on Apple's developer site. But it is definitely part of the public API.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/1561554/Cocoa-Touch:%20How%20do%20I%20see%20if%20two%20NSDates%20are%20in%20the%20same%20day?/28247598">Stack Overflow</a>.</p>
comments powered by Disqus