我有日期的字符串值(例如: 2012-11-30T12:45:00Z ),我怎样才能得到这样的价值: 12:45 ?感谢..
答案 0 :(得分:4)
日期格式化程序方法如下所示:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"hh:mm"];
NSString *hhmm = [dateFormatter stringFromDate:theDate];
// release dateFormatter if not using ARC... but use ARC
答案 1 :(得分:-2)
NSString* timeStr = [longDateStr substringWithRange:NSMakeRange(11, 5)];