获取当天凌晨的时间
作者:
梦在旅途 | 来源:发表于
2016-08-06 14:03 被阅读47次NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
[calendar setTimeZone:gmt];
NSDate *date = [NSDate date];
NSDateComponents *components = [calendar components:NSUIntegerMax fromDate:date];
components.day-=1;
[components setHour:0];
[components setMinute:0];
[components setSecond: 0];
NSDate *startDate = [calendar dateFromComponents:components];
NSDate *endDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:1 toDate:startDate options:0];
NSLog(@"%@", endDate);
本文标题:获取当天凌晨的时间
本文链接:https://www.haomeiwen.com/subject/srmksttx.html
网友评论