//1),创建一个对象,赋值为当前日期date 创建的NSDate对象,获得的永远是0时区的时间,china是东八区,需要加上8个小时
NSDate *date = [NSDate date];
NSTimeZone *zone = [NSTimeZone systemTimeZone];//修改时区
NSInteger interval1 = [zone secondsFromGMTForDate: date];//修改时区
NSDate *localDate1 = [date dateByAddingTimeInterval: interval1];//修改时区
NSLog(@"今天%@", localDate1);
//2),创建一个明天此时的日期(时间间隔是以秒为单位的)dateWithTimeIntervalSinceNow:
NSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:24 * 60 * 60];
NSInteger interval2 = [zone secondsFromGMTForDate: tomorrow];
NSDate *localDate2 = [tomorrow dateByAddingTimeInterval: interval2];
NSLog(@"明天%@", localDate2);
//3),创建一个昨天此时的日期
NSDate *yesterday = [NSDate dateWithTimeIntervalSinceNow:-24 * 60 * 60];
NSInteger interval3 = [zone secondsFromGMTForDate: yesterday];
NSDate *localDate3 = [yesterday dateByAddingTimeInterval: interval3];
NSLog(@"昨天%@", localDate3);