Instance Method

stringFromDate:toDate:

Returns a formatted string based on the time difference between two dates.

Declaration

- (NSString *)stringFromDate:(NSDate *)startDate toDate:(NSDate *)endDate;

Parameters

startDate

The start time. This parameter must not be nil.

endDate

The end time. This parameter must not be nil.

Return Value

A formatted string representing the specified time information.

Discussion

This method calculates the elapsed time between the startDate and endDate values and uses that information to generate the string. For example, if there is exactly one hour and ten minutes difference between the start and end dates, generating an abbreviated string would result in a string of “1h 10m”.

See Also

Formatting Values

- stringFromDateComponents:

Returns a formatted string based on the specified date component information.

- stringForObjectValue:

Returns a formatted string based on the date information in the specified object.

- stringFromTimeInterval:

Returns a formatted string based on the specified number of seconds.

+ localizedStringFromDateComponents:unitsStyle:

Returns a localized string based on the specified date components and style option.