mirror of
https://github.com/hex248/ob248.com.git
synced 2026-02-08 02:33:02 +00:00
rounded AGE: Xy to 2dp
This commit is contained in:
@@ -12,8 +12,9 @@ const uniqueId = `time-since-${Math.random().toString(36).substring(2, 9)}`;
|
|||||||
let msElapsed = 0;
|
let msElapsed = 0;
|
||||||
|
|
||||||
function updateTimeAlive() {
|
function updateTimeAlive() {
|
||||||
let years = Math.floor(
|
let years = roundToDp(
|
||||||
(currentTimeMS - dateMS + msElapsed) / (60 * 60 * 24 * 365 * 1000)
|
(currentTimeMS - dateMS + msElapsed) / (60 * 60 * 24 * 365 * 1000),
|
||||||
|
2
|
||||||
);
|
);
|
||||||
let milliseconds = currentTimeMS - dateMS + msElapsed;
|
let milliseconds = currentTimeMS - dateMS + msElapsed;
|
||||||
|
|
||||||
@@ -23,6 +24,11 @@ const uniqueId = `time-since-${Math.random().toString(36).substring(2, 9)}`;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function roundToDp(num, dp) {
|
||||||
|
const factor = Math.pow(10, dp);
|
||||||
|
return Math.round(num * factor) / factor;
|
||||||
|
}
|
||||||
|
|
||||||
updateTimeAlive();
|
updateTimeAlive();
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user