Skip to content

Instantly share code, notes, and snippets.

@cbess
Last active December 25, 2015 14:39
Show Gist options
  • Save cbess/6993054 to your computer and use it in GitHub Desktop.
Save cbess/6993054 to your computer and use it in GitHub Desktop.
Time formatted string from seconds.
/**
* Returns the human-readable string that represents the specified seconds.
* @discussion Ex: seconds = 4017 -> "01:06:57"
*/
- (NSString *)timeStringFromSeconds:(NSInteger)seconds
{
int hours = seconds / 3600;
int rem = seconds % 3600;
int minutes = rem / 60;
int remSecs = rem % 60;
return [NSString stringWithFormat:@"%.2d:%.2d:%.2d", hours, minutes, remSecs];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment