简体   繁体   English

我如何将我的正常运行时间命令的格式更改为当前时间,我想将其更改为几天

[英]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: 将小时数转换为天数将非常简单-您只需将其除以24并取整:

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

Hopefully this helps! 希望这会有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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