NSString NSDate 计算时间差

来源:互联网 发布:有首单立减的外卖软件 编辑:程序博客网 时间:2024/05/21 06:56

    NSDate * now = [NSDatedate];

    NSDateFormatter *df = [[NSDateFormatteralloc] init];

    [df setDateFormat:@"yyyy-MM-dd"];

    NSLocale *locale = [[NSLocalealloc] initWithLocaleIdentifier:@"en_US"];//本地化

    [df setLocale:locale];

    NSString *myDateString = @"2013-04-09";

    NSDate *myDate = [dfdateFromString:myDateString];

    NSTimeInterval timeBetween = [nowtimeIntervalSinceDate:myDate];

    NSLog(@"%f",timeBetween);

0 0
原创粉丝点击