Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Get Date Interval in iPhone

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 571
    Comment on it

    Compare two dates to get number of days without calculation.

    1 day = 86400 seconds..

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"EE LLL d,yyyy"];
    NSString *dateStr = @"Tue Dec 17, 2013";
    
    NSDate *date = [dateFormat dateFromString:dateStr];
    if ([[NSDate date] timeIntervalSinceDate:date]>86400) {
        NSLog(@"%f", [[NSDate date] timeIntervalSinceDate:date]/86400);
    }
    

    Dividing date interval by 86400seconds gives number of days.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: