简体   繁体   中英

How do I change the format for my uptime command its currently hours I would like to change it to days

I need to change my return time settings from hours to days. I've tried to expand the hours but I keep getting errors.

let totalSeconds = (client.uptime / 1000);
let hours = Math.floor(totalSeconds / 3600);
totalSeconds %= 3600;
let minutes = Math.floor(totalSeconds / 60);
let seconds = totalSeconds % 60;
// Then you'll have hours, minutes and seconds ready to use.

let uptime = `${hours} hours, ${minutes} minutes and ${seconds} seconds`;

I just keep getting errors.

Converting hours to days would be extremely simple - you just divide by 24 and floor it:

var days = Math.floor(hours / 24);

Hopefully this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM