Convert seconds to days, minutes, and hours in Obj-c

后端 未结 11 2381
[愿得一人]
[愿得一人] 2020-12-13 01:16

In objective-c, how can I convert an integer (representing seconds) to days, minutes, an hours?

Thanks!

11条回答
  •  一整个雨季
    2020-12-13 01:44

    Try doing the following:

        x=int(input("enter a positive integer: "))
        sec = int(x % 60);
        minu =int((x % 3600) / 60);
        ho =int((x % 86400) / 3600);
        days =int(x / (60 * 60 * 24));
        print(int(days),"days", ho,"hours", minu , "minutes" , sec ,"seconds" )
    

提交回复
热议问题