0

I want to know how to convert seconds to minutes and days according to the URL am getting via web-service-

enter image description here

I have to use those seconds as to display user's last activity-

enter image description here

how can I do that???

Avi
  • 7,298
  • 1
  • 19
  • 22
pri
  • 77
  • 10

1 Answers1

1

I use this method to get total hour,minutes and seconds for my audio or video player to display duration of it. Method is like,

 - (NSString *)timeFormatted:(int)totalSeconds
{

int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int hours = totalSeconds / 3600;

NSString *finalString;

if (hours > 0) {

    finalString = [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds];

}

else{


    finalString = [NSString stringWithFormat:@"%02d:%02d", minutes, seconds];

}

return finalString;
}

you can make method something like this.

hint :

You can get days something like,

 int days = totalSeconds / 86400;
Ketan Parmar
  • 26,610
  • 9
  • 47
  • 70
  • You can display that final string as your label's text, for exa, `yourLabel.text = finalString`. For that you have to call this function like `NSString *finalString = [self timeFormatted:45000];` – Ketan Parmar Jul 25 '16 at 13:16