由於我從服務器得到的響應看起來像這樣 - (StartTime =「19/02/2016 13:52」),我想用這個替換這個字符串 - (StartTime =「19/02/2016在下午1時52分「)......我想在年底追加AM/PM,我使用此代碼...Nsdate總是返回空
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yyyy HH:mm"];
NSDate *date = [[NSDate alloc]init];
date = [dateFormatter dateFromString:userRide.journeyStartTime];
[dateFormatter setDateFormat:@"MM/dd/yyyy 'at' HH:mm a"];
NSLog(@"date1 : %@", date);
NSString *string = [dateFormatter stringFromDate:date];
但NSDate的總是返回空... 請幫助...
'13:52 PM'切換是多餘的,無論是'13:52'或'1:52 PM' – luk2302