-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (29 loc) · 932 Bytes
/
Copy pathscript.js
File metadata and controls
31 lines (29 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Change this if update (unlikely)
var updateDate = {
year: 2025,
month: 7,
day: 7
}
var lastUpdate = new Date();
lastUpdate.setFullYear(updateDate.year, updateDate.month-1, updateDate.day);
var timeSince = new Date().getTime() - lastUpdate.getTime();
var dateSince = new Date();
dateSince.setTime(timeSince);
var display = document.querySelector("#time");
// formatting is my passion
display.innerText =
(dateSince.getFullYear() - 1970 > 0
? ` ${dateSince.getFullYear() - 1970} year${
dateSince.getFullYear() - 1970 !== 1 ? "s" : ""
}${dateSince.getMonth() > 0 ? ',' : ''}`
: "") +
(dateSince.getMonth() > 0
? ` ${dateSince.getMonth()} month${
dateSince.getMonth() !== 1 ? "s" : ""
}`
: "") +
(dateSince.getDate() > 0
? `${dateSince.getFullYear() - 1970 > 0 || dateSince.getMonth() > 0 ? ' and' : ''} ${dateSince.getDate()} day${
dateSince.getDate() !== 1 ? "s" : ""
}`
: "");