-1

如果我得到格式的字符串日期@"MM/dd/YYYY h:mm a"并且我有日期的时区(字符串日期),我怎样才能将它转换为 UTC 数字?

4

1 回答 1

0

尝试这个

    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];
于 2013-03-24T17:25:11.757 回答