64 lines
1.9 KiB
HTML
64 lines
1.9 KiB
HTML
^-^ <a id="inconspicuous-timer-a" href="/images/secret.jpg"><i id="inconspicuous-timer"></i></a>
|
|
|
|
<script>
|
|
|
|
function getTimeSince(dateString) {
|
|
// Parse the input date string into a Date object
|
|
const startDate = new Date(dateString);
|
|
|
|
// Get the current date
|
|
const currentDate = new Date();
|
|
|
|
// Calculate the differences in each unit
|
|
let years = currentDate.getFullYear() - startDate.getFullYear();
|
|
let months = currentDate.getMonth() - startDate.getMonth();
|
|
let days = currentDate.getDate() - startDate.getDate();
|
|
let hours = currentDate.getHours() - startDate.getHours();
|
|
let minutes = currentDate.getMinutes() - startDate.getMinutes();
|
|
|
|
// Adjust for negative month difference
|
|
if (months < 0) {
|
|
years--;
|
|
months += 12;
|
|
}
|
|
|
|
// Adjust for negative day difference
|
|
if (days < 0) {
|
|
months--;
|
|
let prevMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0).getDate();
|
|
days += prevMonth;
|
|
}
|
|
|
|
// Adjust for negative hour difference
|
|
if (hours < 0) {
|
|
days--;
|
|
hours += 24;
|
|
}
|
|
|
|
// Adjust for negative minute difference
|
|
if (minutes < 0) {
|
|
hours--;
|
|
minutes += 60;
|
|
}
|
|
|
|
return {
|
|
years: years,
|
|
months: months,
|
|
days: days,
|
|
hours: hours,
|
|
minutes: minutes
|
|
};
|
|
}
|
|
// Set the date we're counting up from
|
|
const startDate = new Date("Dec 28, 2023 16:34:56");
|
|
|
|
function updateHtml() {
|
|
const result = getTimeSince("Dec 28, 2023 16:34:56");
|
|
const timerElement = document.getElementById("inconspicuous-timer")
|
|
timerElement.innerHTML = `${result.years}y ${result.months}m ${result.days}d ${result.hours}h ${result.minutes}min`;
|
|
}
|
|
|
|
updateHtml()
|
|
|
|
var x = setInterval(updateHtml, 10000);
|
|
</script>
|