我在iPhone應用程序中遇到了一個問題。格式爲'hh:mm a'的NSDateFormatter dateFromString返回零
在我的應用程序我轉換器具時間字符串到日期的那樣
NSString *time = @"01:30 PM";
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"hh:mm a"];
NSDate *date = [dateFormat dateFromString:time];
,由於某種原因一直date
爲零[dateFormat dateFromString:time]
後。
誰能告訴我我做錯了什麼?
感謝
沒有它的正常工作輸出:2000-01-01 08:00:00 +0000 –
你需要顯示什麼? –
我有幾個格式爲hh:mm a的字符串,我需要在它們之間進行比較,所以我想將它們轉換爲NSDate進行比較 – user3414609