nsdate相关内容
由于 NSDateCompoments,我正在使用递增/递减的 NSDate: dateComponents = [[NSDateComponents alloc] init];self.date = [gregorian dateByAddingComponents:dateComponents toDate:[NSDate date] options:0]; ... [dateCompo
..
我下面的代码工作正常.我不知道为什么它有时会崩溃(主要是在应用程序启动时.大约 100 个中的 1 个). extension Formatter {静态 let enUSPOSIX: DateFormatter = {让格式化程序 = DateFormatter()formatter.locale = Locale(identifier: "en_US_POSIX")//返回格式化程序}()}
..
当我说不在后台运行时,我的意思是当用户双击他们的主页按钮并向上滑动时,该按钮将重新启用 这是我的viewDidLoad 中的代码 if let waitingDate:Date = UserDefaults.standard.value(forKey: "waitingDate") as?日期{让 currentDate = Date()if(currentDate.compare(wa
..
我有以下 NSDateFormatter: NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];[dateFormatter setDateFormat:@"MMM.d, yyyy"];NSLocale *usLocal = [[NSLocale alloc] initWithLocaleIdentifier:@"en_
..
结果仍然是前一天,我只是问自己为什么,因为 NSTimeZone 设置正确并且适合我的国家(意大利,罗马)这是我的代码存根,有什么想法吗? NSString *dateString = @"03/07/2008";NSDateFormatter *formatter = [[NSDateFormatter alloc] init];[格式化程序 setFormatterBehavior:[NS
..
我有一个带有 nextCheck (NSDate)、lastName (NSString) 和 firstName (NSString) 键的数组控制器.我已经为数组设置了排序描述符.正如你在下面看到的,我首先按 nextCheck 排序,然后是 lastName,然后是 firstName.这似乎不起作用,因为 NSDate 不仅由日期组件组成,还由时间组件组成.有没有一种简单的方法可以只按日期
..
我的任务是将字符串解析为 NSDate.我用以下代码做得很好: NSString* timeStr = @"15:00:00"NSDateFormatter *formatter = [[NSDateFormatter alloc] init];[formatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]];[
..
我一直在努力将 nsstring 转换为 nsdate 格式.我有一个像 (2011-08-25 18:30:00 +0000) 这样的 nsstring 格式的日期,但我想将它更改为 nsdate 格式 (08/26/2011).如何改变它?任何人都可以帮助我吗?在此先感谢...我花了一天时间来解决这个问题,但我找不到解决方案...请帮助我的朋友.... 这是我的代码, NSStrin
..
我想要给定数字的星期几,这是伪代码: getDayStringForInt:0 = 星期日getDayStringForInt:1 = 星期一getDayStringForInt:2 = 星期二getDayStringForInt:3 = 星期三getDayStringForInt:4 = 星期四getDayStringForInt:5 = 星期五getDayStringForInt:6 = 星
..
我需要将 RESTful 放到服务器上.Date 必须像 Sat, 19 Jan 2013 04:09:58 GMT 一样使用. 在 objc 中我写了这个: NSDateFormatter* _GMTDateFormatter = [[NSDateFormatter alloc] init];[_GMTDateFormatter setDateFormat:@"EEE, dd MMM y
..
我有一组事件对象.对象有几个属性.属性之一是 NSDate eve_date. 现在我想检查该对象数组是否包含某个 NSDate d 我正在做以下事情 if([[matches valueForKey:@"eve_date"] containsObject:d]){NSLog(@"包含对象");}别的{NSLog(@"不包含对象");} 但这行不通.有人可以帮我吗? 亲切的问
..
我正在尝试解析 RSS 提要,但日期很难解析.日期字符串为:publishedDate = "2013-01-08T20:09:02.000Z" 这是我的代码: NSDateFormatter *utc = [[NSDateFormatter alloc] init];[utc setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];[utc s
..
我从服务器收到一个字符串,其日期如下所示:“2013-03-29T15:27:00Z".如何格式化它并将其转换为 NSDate? 解决方案 试试这个: [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];NSDateFormatter *formatter = [[[NSDateFormatt
..
我正在开发一个应用程序,该应用程序需要使用国定假日的日期. 在下面,我能够获得阵亡将士纪念日: //为阵亡将士纪念日(五月的最后一个星期一)设置组件让 MemorialDayComps = NSDateComponents()MemorialDayComps.weekday = 2MemorialDayComps.month = 5MemorialDayComps.year = curre
..
我正在尝试从两个日期和 我成功获取图像. 使用 PHAsset 库 现在的问题是我无法在同一天的两次之间获取图像,例如在 12:10PM 到 12:30PM 之间 使用下面的代码 NSDate *startDate = [self getDateForDay:30 andMonth:9 andYear:2016 andHour:12 andMinute:10 andSecond:0
..
假设我有以下初始化 NSDateComponents 的代码: NSCalendar *calendar = [NSCalendar currentCalendar];NSDateComponents *components = [[NSDateComponents alloc] init];[组件设置年份:1987];[组件设置月份:3];[组件 setDay:17];[组件设置时间:14];
..
我的问题与下面代码片段中给出的 NSDateComponents 操作的时间配置文件有关. 我有一个方法可以遍历大量 NSDate 对象 部分方法要求我丢弃每个日期的小时、分钟和秒. 为此,我有 3 个步骤: 我从原始日期创建了一个 NSDateComponents 对象. 我将 H:M:S 元素设置为 0 我根据需要将 H:M:S 设置为 0 的新日期对象 问题:
..
如何将时间字符串(24 小时格式)转换为 NSDate 进行比较? 我在这里得到零和错误的 NSDate: let a = "5:46"让 b = "24:30"让 dateFormatter = NSDateFormatter()dateFormatter.timeStyle = .ShortStyledateFormatter.dateFormat = "k:mm"//k = 1~24
..
我一直在使用此方法将常规 NSString 对象转换为 NSDate,但尝试向 Apple 提交更新并被拒绝.在 iOS 中执行此操作的另一种方法是什么? NSString *date_str = @"2011-08-12T12:20:00Z";NSDate *the_date = [NSDate dateWithNaturalLanguageString:date_str locale:[[N
..
我有一个日期字符串,如下所示:“Fri, 17 Jun 2011 19:20:51 PDT",我需要将其解析为 NSDate 格式. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];[dateFormatter setDateFormat:@"EEE, d MM YYYY HH:mm:ss zzz"];NSDate
..