我想得到两个时间值,它们是这样的字符串格式:
例如:
NSString *fromTime=@"11:30";
NSString *toTime=@"12:30";
我想要时间格式,我尝试使用 NSDateFormatter,
`NSDateFormatter *df=[[NSDateFormatter alloc] init];
[df setDateFormat:@"HH:mm"];
NSDate *from=[df dateFromString:fromTime];
NSLog(@"from %@",from);
NSDate *to=[df dateFromString:toTime];
NSLog(@"to %@",to);`
输出:从 1970-01-01 06:00:00 +0000 到 1970-01-01 07:00:00 +0000
但我只想要时间。