Ios 如何转换格式为“@”的包含日期的字符串;年月日:年月日;到UTC的秒数
如果我获得格式为“MM/dd/YYYY h:MM a”的字符串日期,并且我有日期时区(字符串日期),如何将其转换为UTC编号?试试这个Ios 如何转换格式为“@”的包含日期的字符串;年月日:年月日;到UTC的秒数,ios,objective-c,ios5,ios6,Ios,Objective C,Ios5,Ios6,如果我获得格式为“MM/dd/YYYY h:MM a”的字符串日期,并且我有日期时区(字符串日期),如何将其转换为UTC编号?试试这个 NSString *dateString = @"03/23/2012 09:17 PM"; //It is assumed that the time in dateString wrt local time zone NSDateFormatter *dateFormatter = [NSDateFormatter new];
NSString *dateString = @"03/23/2012 09:17 PM";
//It is assumed that the time in dateString wrt local time zone
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:@"MM/dd/yyyy h:mm a"];
NSDate*date = [dateFormatter dateFromString:dateString];
NSTimeInterval timeInSeconds = [date timeIntervalSince1970];
“日期时区(字符串日期)”是什么意思?你能给出一个具体的例子吗?你看起来和阅读NSDate的规范很相似吗?