iOS NSDateFormatter and Compare Two Date
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setLocale:[NSLocale currentLocale]]; [dateFormat setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; [dateFormat setDateFormat:@"yyyy/MM/dd"]; NSDate *date = [dateFormat dateFromString:@"2013/5/23"]; NSString *selectionString = [dateFormat stringFromDate:date]; SO Link( http://stackoverflow.com/questions/12721553/get-time-from-nsdate-returns-nil/12721934#12721934 ) Imp Link (http://ios.eezytutorials.com/) The most commonly used date format specifiers are (keep in mind that they are case sensitive): y = year Q = quarter M = month w = week of year W = week of month d = day of the month D = day of year E = day of week a = period (AM or PM) h = hour (1-12) H = hour (0-23) m = minute s = second In general, the number of characters in a specifier determine the size of date field. Let’s use an example to illustrate date formatting. eg. Input date = 2011-05-01 Sunday ...