2011-01-27 102 views
4

我有一個格式爲2011年1月25日3:17 AM的字符串。我需要將其轉換爲NSDate。 我使用格式爲@「MMM d,yyyy h:mm a」的NSDateFormatter。如果iphone時間格式爲12小時,則工作正常,但如果時間格式爲24小時,則返回nil。誰能幫我這個????當時間爲24小時格式時,NSString的NSDate

回答

2

這是在NSDateFormatter的錯誤。您可以通過在日期格式化程序上手動設置區域設置來解決該問題:

[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"] autorelease]]; 
相關問題