Closed
Description
- Version: 10.15.2
- Platform:Linux discord-Inspiron-560 5.3.0-23-generic docs: Change contributing documentation to io.js node#25-Ubuntu SMP Tue Nov 12 09:22:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: os
Trying to make a function that sends the server uptime. When I run uptime
, I get:
11:35:04 up 18 days, 17:39, 7 users, load average: 0.09, 0.10, 0.09
So this is saying my server has been up for 18 days, 17 hours, and 39 minutes, correct? So, my script for calculating time is this (its the same as my discord.js client.uptime script, which ive proved over 72 hours works fine in internal testing) is:
var serverUptime = os.uptime();
let serverSeconds = (serverUptime / 1000);
let sdays = Math.floor(serverSeconds / 86400);
let shours = Math.floor(serverSeconds / 3600) - (sdays * 24);
serverSeconds %= 3600;
let sminutes = Math.floor(serverSeconds / 60);
let sseconds = Math.floor(serverSeconds % 60);
var serverUptimeCalc = `${sdays} days, ${shours} hours, ${sminutes} minutes and ${sseconds} seconds`;
This should give me the uptime, correct? Well, no. When I print serverUptimeCalc, I get:
0 days, 0 hours, 26 minutes and 59 seconds
I ran this 10 minutes ago, and it gave me 26 minutes 58 seconds.
Is this a bug, or am I just terrible at making time scripts?
Metadata
Metadata
Assignees
Labels
No labels