help with console time

I know that this isn't even discord.js question, but Im just too dumb to fix it and I dont know what to do please help :( Im trying to count time in my bot console. Works, but after 24 hours doesnt show 1d, 0h, 0s, instead, it says something like this 75141d, 21h, 49s (this isnt a screenshot of exact 24 hours, actually its like 3 days) here's my code:
let totalDays = 0;
setInterval(function() {
let uptime = '';
let totalSeconds = Math.floor(client.uptime / 1000);

let seconds = totalSeconds % 60;
totalSeconds = Math.floor(totalSeconds / 60);

let minutes = totalSeconds % 60;
totalSeconds = Math.floor(totalSeconds / 60);

let hours = totalSeconds % 24;
let days = Math.floor(totalSeconds / 24);
totalDays += days;

if (totalDays > 0) {
uptime += `${totalDays}d, `;
}
if (hours > 0) {
uptime += `${hours}h, `;
}
if (minutes > 0) {
uptime += `${minutes}m, `;
}
uptime += `${seconds}s`;

process.stdout.write(`Time: \x1b[34m${uptime}\x1b[0m`);
}, 1000);
setInterval(function() {
process.stdout.write("\r\x1b[K")
}, 999);
let totalDays = 0;
setInterval(function() {
let uptime = '';
let totalSeconds = Math.floor(client.uptime / 1000);

let seconds = totalSeconds % 60;
totalSeconds = Math.floor(totalSeconds / 60);

let minutes = totalSeconds % 60;
totalSeconds = Math.floor(totalSeconds / 60);

let hours = totalSeconds % 24;
let days = Math.floor(totalSeconds / 24);
totalDays += days;

if (totalDays > 0) {
uptime += `${totalDays}d, `;
}
if (hours > 0) {
uptime += `${hours}h, `;
}
if (minutes > 0) {
uptime += `${minutes}m, `;
}
uptime += `${seconds}s`;

process.stdout.write(`Time: \x1b[34m${uptime}\x1b[0m`);
}, 1000);
setInterval(function() {
process.stdout.write("\r\x1b[K")
}, 999);
if this get deleted or something I understand :AC_bocchi_sad:
5 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
chewie
chewie17mo ago
#other-js-ts
TRKako
TRKakoOP17mo ago
what, I didnt know that exist
chewie
chewie17mo ago
Now you do reallyFckingCuteCatThumbsUp
TRKako
TRKakoOP17mo ago
sorry, im going there perro
Want results from more Discord servers?
Add your server