I am trying to create a 24hr timer on a database using quick.db, but my timer isn't ticking, and time logs negative number.
const db = require('quick.db');
const Discord = require('discord.js');
const ms = require('parse-ms');
let timer = await db.fetch(`daily_timer`);
let timeout = 86400000;
if (timer !== null && timeout - (Date.now() * -2 - timer) > 0) {
let time = ms(timeout - (Date.now() * -2 - timer));
console.log(time);
etc..
};
If the * -2
is removed from let time = ..
then it logs everything as negative.
Date.now()
returns as normal.
console.log for time:
{ days: -18950, hours: -9, minutes: -56, seconds: -51, milliseconds: -673, microseconds: -0, nanoseconds: -936 }
console.log for Date.now():
1637488611676
Any help would be appreciated, as I really have no idea why the time is negative.