我想为每个用户时区时间设置通知默认上午 9:00。
如何为默认时间 9:00 am 创建 触发日期。
Best Answer-推荐答案 strong>
你好,我知道了答案:-
NSDate *pickerDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormatT_FORMATE_BIRTHDATE];
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviationT_TIME_ZONE_GMT];
[dateFormatter setTimeZone:gmt];
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents *timeComponents = [calendar components NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit )
fromDate:pickerDate];
[timeComponents setHour:9];
[timeComponents setMinute:00];
[timeComponents setSecond:0];
NSDate *dtFinal = [calendar dateFromComponents:timeComponents];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat"yyyy-MM-dd HH:mm:ss Z"];
NSString *fierDate = [formatter stringFromDate:dtFinal];
关于ios - 本地通知设置默认时间 9 :00 am for user timezone in iOS,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/30998833/
|