gpt4 book ai didi

ios - 本地通知设置默认时间 9 :00 am for user timezone in iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:14:47 26 4
gpt4 key购买 nike

我想为每个用户时区时间设置通知默认上午 9:00

如何为默认时间 9:00 am 创建开火日期

最佳答案

你好,我知道了答案:-

NSDate *pickerDate = [NSDate date]; 
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:DT_FORMATE_BIRTHDATE];
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:DT_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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com