6 |
const seconds = Math.floor((Date.now() - date) / 1000); |
const seconds = Math.floor((Date.now() - date) / 1000); |
7 |
let interval = seconds / (60 * 60 * 24 * 30 * 365); |
let interval = seconds / (60 * 60 * 24 * 30 * 365); |
8 |
|
|
9 |
if (interval > 1) { |
if (interval >= 1) { |
10 |
return Math.floor(interval) + " year" + (Math.floor(interval) === 1 ? '' : 's'); |
return Math.floor(interval) + " year" + (Math.floor(interval) === 1 ? '' : 's'); |
11 |
} |
} |
12 |
|
|
13 |
interval = seconds / (60 * 60 * 24 * 30); |
interval = seconds / (60 * 60 * 24 * 30); |
14 |
|
|
15 |
if (interval > 1) { |
if (interval >= 1) { |
16 |
return Math.floor(interval) + " month" + (Math.floor(interval) === 1 ? '' : 's'); |
return Math.floor(interval) + " month" + (Math.floor(interval) === 1 ? '' : 's'); |
17 |
} |
} |
18 |
|
|
19 |
interval = seconds / (60 * 60 * 24); |
interval = seconds / (60 * 60 * 24); |
20 |
|
|
21 |
if (interval > 1) { |
if (interval >= 1) { |
22 |
return Math.floor(interval) + " day" + (Math.floor(interval) === 1 ? '' : 's'); |
return Math.floor(interval) + " day" + (Math.floor(interval) === 1 ? '' : 's'); |
23 |
} |
} |
24 |
|
|
25 |
interval = seconds / (60 * 60); |
interval = seconds / (60 * 60); |
26 |
|
|
27 |
if (interval > 1) { |
if (interval >= 1) { |
28 |
return Math.floor(interval) + " hour" + (Math.floor(interval) === 1 ? '' : 's'); |
return Math.floor(interval) + " hour" + (Math.floor(interval) === 1 ? '' : 's'); |
29 |
} |
} |
30 |
|
|
31 |
interval = seconds / 60; |
interval = seconds / 60; |
32 |
|
|
33 |
if (interval > 1) { |
if (interval >= 1) { |
34 |
return Math.floor(interval) + " minute" + (Math.floor(interval) === 1 ? '' : 's'); |
return Math.floor(interval) + " minute" + (Math.floor(interval) === 1 ? '' : 's'); |
35 |
} |
} |
36 |
|
|