发布网友 发布时间:2024-05-30 21:11
共1个回答
热心网友 时间:2024-06-13 10:57
代码如下:NSDateFormatter *df=[[NSDateFormatter alloc] init];// Set the date format according to your needs[df setDateFormat:@"MM/dd/YYYY hh:mm a"]; //for 12 hour format//[df setDateFormat:@"MM/dd/YYYY HH:mm "] // for 24 hour formatNSDate *date1 = [df dateFromString:firstDateString];NSDate *date2 = [df dateFromString:secondDatestring];NSLog(@"%@f is the time difference",[date2 timeIntervalSinceDate:date1]);[df release];