1 // 当前时间创建NSDate
NSDate *myDate = [NSDate date];
NSLog(@"myDate = %@",myDate);
2 //从现在开始的24小时
NSTimeInterval secondsPerDay = 24*60*60;
NSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:secondsPerDay];
NSLog(@"myDate = %@",tomorrow);
3//根据已有日期创建日期
NSTimeInterval secondsPerDay1 = 24*60*60;
NSDate *now = [NSDate date];
NSDate *yesterDay = [now addTimeInterval:-secondsPerDay1];
NSLog(@"yesterDay = %@",yesterDay);
4//比较日期
BOOL sameDate = [now isEqualToDate:yesterDay];
NSLog(@"sameDate = %lu",sameDate);
|
|