Search code examples
objective-cnsdatenstimeinterval

How to get hours and minutes from interval of seconds in objective c


I have a time difference between two datetimes. The interval in seconds is 3660 which means 1 hour and 1 minute ago. How can i show the interval of seconds in hours and minutes like i said before? i can get the hours by doing (3600/60)/60 which gives me the one hour but how do i get the remaining minutes along with the hour?

Any help appreciated.


Solution

  • Something like this:

    int totalTime = 3660;
    int hours = totalTime / 3600;
    int minutes = (totalTime % 3600) / 60;