Common iOS time methods
// Date before the current day
NSDate * today = [NSDate date];
// Time Zone
NSTimeZone * zone = [NSTimeZone systemTimeZone];
// Set the interval
_ Interval = [zone secondsFromGMTForDate: today];
// Today + 8 hours (China Shanghai time zone)
Today = [today dateByAddingTimeInterval: _ interval];
// Obtain tomorrow's date
NSDate * tomorrowDate = [[NSDate alloc] initWithTimeInterval: 24*60*60 sinceDate: [NSDate date];
// Calendar
NSCalendar * calendar = [NSCalendar currentCalendar];
// Information such as time, year, month, and day can be separated from comps.
NSDateComponents * comps = [calendar components :( NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | bytes | NSHourCalendarUnit) fromDate: tomorrowDate];
// Obtain the current day of the week
NSInteger weekday = [comps weekday];
// Convert the NSString type to NSDate
NSDate * serverDate = [dateFomatter dateFromString: serverTimeStr];
NSDate * createDate = [dateFomatter dateFromString: createTimeStr];
// Calculate the interval between two dates
NSTimeInterval betweenTime = [serverDate timeIntervalSinceDate: createDate];
// Separate the year, month, day, hour, minute, and second in the standard format
NSDateFormatter * dateFomatter = [[NSDateFormatter alloc] init];
[DateFomatter setDateFormat: @ "yyyy-MM-dd HH: mm: ss"];
// Replace string with formatter
NSDate * stringDate = [dateFomatter dateFromString: string];
// Formatter is month and day
[DateFomatter setDateFormat: @ "MM-dd"];
// Extract the string month and day
NSString * str1 = [dateFomatter stringFromDate: stringDate];