2

我有日期字符串值(例如:2012-11-30T12:45:00Z),我怎样才能得到这样的值:12:45?谢谢..

4

2 回答 2

4

日期格式化程序方法如下所示:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"hh:mm"];
NSString *hhmm = [dateFormatter stringFromDate:theDate];

// release dateFormatter if not using ARC... but use ARC
于 2012-10-11T16:49:36.540 回答
-2
NSString* timeStr = [longDateStr substringWithRange:NSMakeRange(11, 5)];
于 2012-10-11T16:44:05.097 回答