Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个格式为“2012-09-06 04:57:00.000”的日期字符串。我需要像这样在凌晨 04:57 分隔那个字符串中的时间。帮我解决这个问题?
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"hh:mm:ss a"]; NSString *timeStr = [formatter stringFromDate:[NSDate date]];
上面的代码与 ARC 一起使用,否则您需要发布格式化程序,例如
formatter release