How to check if two NSDates are from the same day [duplicate]

NSCalendar has a method that does exactly what you want actually!

/*
    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);

So you’d use it like this:

[[NSCalendar currentCalendar] isDate:date1 inSameDayAsDate:date2];

Or in Swift

Calendar.current.isDate(date1, inSameDayAs:date2)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)