我有一個NSDate
值,看起來像這樣2013-03-20
,我認爲這是YYYY-MM-dd
。我想知道如何reformat
它看起來像這樣20-March-2013
但我只是無法弄清楚。NSDate格式導致重新格式化
這是我試過的,但它返回null。
NSDate *tempsDate = [tempDic objectForKey:@"date"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"ddMMyyyy"];
NSString *textDate = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:tempsDate]];
NSLog(@"Date %@",textDate);
什麼是您當前日誌的日期? – Tirth
所以tempsDate = 2013-03-20 和我的NSLog =「日期(空)」 – HurkNburkS
嘗試Mutawe回答。 – Tirth