Tag: date

使用Google OAuth API检索出生date

有没有人知道如何通过Google OAuth API来检索DOB? 我可以通过将范围设置为https://www.googleapis.com/auth/userinfo.profile来获取名称,电子邮件,性别等其他信息。 但是我不能在这个范围内获得DOB。

如何parsingISO8601date

我有这种格式的datestring: 2011-12-29T09:09:06-0500 我怎样才能把它转换成date对象?

从date排列中找出日子

我有一个类似下面的数组 _combinedBirthdates( "03/12/2013", "03/12/2013", "08/13/1990", "12/09/1989", "02/06", "09/08", "03/02/1990", "08/22/1989", "03/02", "05/13", "10/16", "07/08", "08/31/1990", "04/14/1992", "12/15/1905", "08/14/1989", "10/07/1987", "07/25", "07/17/1989", "03/24/1987", "07/28/1988", "01/21/1990", "10/13" ) 这一切都是NSString 我正在尝试从这个包含几天剩下的事情如下所示的新数组 (特定出生date剩余的天数)(我们将比较当前date与上面的date列表,我们会发现剩余的天数)_newarray(“125”,“100”,“65”,并最终像这样..) 我正在使用下面的代码 unsigned int unitFlags = NSDayCalendarUnit; NSCalendar *currCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterShortStyle]; NSLog(@" currCalendar%@",currCalendar); NSMutableArray * _newarray = […]

从iPhone应用程序中了解设备中的date和时间设置

我想知道用户是否已将其设备设置为在iPhone的Settings.app中自动设置date和时间。 我需要这些信息,因为我想让用户只能在应用程序中访问一些信息,只能在第二天再次访问。 但是聪明的用户可以更改date并访问信息。 所以我想检查他们是否自动为设备设置date/时间。 有没有办法做到这一点。 请build议任何其他替代方式,如果存在。 提前致谢。

在iOS中将date转换为时间戳

你如何将任何给定的date转换为毫秒? 例如,2014-01-23到时间戳转换。 NSDate *date = [dateFormatter dateFromString:@"2014-01-23"]; NSLog(@"date=%@",date); NSTimeInterval interval = [date timeIntervalSince1970]; NSLog(@"interval=%f",interval); NSDate *methodStart = [NSDate dateWithTimeIntervalSince1970:interval]; [dateFormatter setDateFormat:@"yyyy/mm/dd "]; NSLog(@"result: %@", [dateFormatter stringFromDate:methodStart]); 产出成果:1970/30/01

在第一个月,NSDate返回错误的date

我的应用程序使用[NSDatedate]函数获取当前date。 上午除了每个月的第一天外,其他日子的工作都很好。 即遵循以下步骤: 将系统date设置为01 – 2011年6月和00.00午夜至5.59 AM之间的时间。 使用以下代码: NSLog(@"Current Date :: %@",[NSDate date]); O / P是::当前date:: 2011-05-31 19:40:21 +0000 所需的O / P是::当前date:: 2011-06-01 00:00:00(即所设定的时间)+0000 也从6上午它工作正常。 这是什么原因? 其实我不希望string格式的NSDate,但我想要的是NSDatedate对象对应于当前月份的第一个date。 为此,我使用下面的代码片段: NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar]; [gregorian setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; NSDateComponents *comp = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[NSDatedate]]; [comp setDay:1]; NSDate *firstDayOfMonthDate = [gregorian dateFromComponents:comp]; [gregorian release]; […]

按stringdatesortingNSDictionaries的NSArray?

我一直在努力寻找一种简单的方法来sorting包含NSDictionaries的NSMutableArray。 每个NSDictionary都有一个名为“Date”的键,它包含一个date的NSString(例如:10/15/2014)。 我正在做的是按升序sorting基于这些string的数组。 我已经试过这个没有运气: NSComparisonResult dateSort(NSString *s1, NSString *s2, void *context) { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"MM/dd/yy"]; NSDate *d1 = [formatter dateFromString:s1]; NSDate *d2 = [formatter dateFromString:s2]; return [d1 compare:d2]; // ascending order return [d2 compare:d1]; // descending order } 我也试过这个没有运气: NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"interest" ascending:YES]; stories=[stories sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]]; recent […]

NSDateFormatter- stringFromDate不返回AM / PM

NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"hh:mm:ss a"]; NSLog(@"Today's Time: %@", [formatter stringFromDate:[NSDate date]]); 上面的代码只是给出了如下的输出: Today's Time: 15:46:43 Today's Time: 3:46 PM Today's Time: 15:46:43我希望输出是Today's Time: 3:46 PM 。 我冲浪了很多,我没有find一个方式来显示上午/下午。 如果有人能帮我find出路,那真的很有帮助。 我正在使用XCode 6.3,我的设备安装了iOS 8.3。

NSDateFormatter“HH”返回在iOS 8设备上午/下午

我现在很难过 我一直很高兴地使用NSDateFormatter没有问题,但今天我注意到,我的一个应用程序给了我一个iPhone的iOS 6加设备与iOS 8.1.3疯狂的结果 – 而它似乎罚款其他设备/模拟器。 看看它有这样的代码: NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; [dateFormatter setDateFormat:@"HH"]; NSInteger hour= [[dateFormatter stringFromDate:datetime] integerValue]; 这样的结果(在设备上)为0-12小时的表示法,因为有一个超出我的理由,如果我在这一点上打印[dateFormatter stringFromDate:datetime],我会得到“下午4点”! 我错过了什么?

在iOS中添加一天到当前date

我看到这个post: iOS和发现明天 。 提供的代码是: units = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; NSDateComponents* comps = [[NSCalendar currentCalendar] components:units fromDate:[NSDate date]]; // Add one day comps.day = comps.day+1; // no worries: even if it is the end of the month it will wrap to the next month, see doc // Recompose a new date, without any time […]