Skip to content

os.uptime is completely broken #2358

Closed
Closed
@amyipdev

Description

@amyipdev

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions