🚗 Shyam Ji Self Drive Car – Freedom on Wheels!Looking for a hassle-free way to travel across Delhi ...
2026-09-10T05:19:37
read more
We hate spam too.
Shyam Ji Self Drive Car – Because Rainy Roads Deserve Happy Drives.
`; // Presumed existing content in updateHtmlString const styleTag = ` `; const updateHtmlString = `${existingContent}${styleTag}`; // Create a div element to act as the shadow host const shadowHost = document.createElement('div'); // Changed 'p' to 'div' for a more common shadow host document.getElementById(id).appendChild(shadowHost); // Corrected the id selection // Attach a shadow root to the shadow host const shadowRoot = shadowHost.attachShadow({ mode: 'open' }); // Insert the HTML string into the shadow root shadowRoot.innerHTML = updateHtmlString; } if (document.getElementById("update-content-html")) { addDynamicHtml('update-content-html'); } function formatHumanReadableDate(timestamp) { const date = new Date(timestamp); const options = { year: "numeric", // e.g., "2024" month: "short", // e.g., "Aug" day: "numeric", // e.g., "23" }; return date.toLocaleDateString("en-IN", options); } // Function to get contextual time (e.g., "3 days ago") function getContextualTime(timestamp) { const now = new Date(); const time = new Date(timestamp); // Calculate the time difference in milliseconds const diff = now - time; // Constants for time calculations const msPerMinute = 60 * 1000; const msPerHour = msPerMinute * 60; const msPerDay = msPerHour * 24; const msPerWeek = msPerDay * 7; const msPerMonth = msPerDay * 30; const msPerYear = msPerDay * 365; // Calculate the time difference in units const daysAgo = Math.floor(diff / msPerDay); const weeksAgo = Math.floor(diff / msPerWeek); const monthsAgo = Math.floor(diff / msPerMonth); const yearsAgo = Math.floor(diff / msPerYear); if (diff < msPerDay && now.getDate() === time.getDate()) { return `Today` } else if (daysAgo === 1) { return `Yesterday` } else if (daysAgo < 7) { return `${daysAgo} days ago`; } else if (weeksAgo < 5) { return `${weeksAgo} week${weeksAgo > 1 ? "s" : ""} ago`; } else if (monthsAgo < 12) { return `${monthsAgo} month${monthsAgo > 1 ? "s" : ""} ago`; } else { return `${yearsAgo} year${yearsAgo > 1 ? "s" : ""} ago`; } } const dateElement = document.querySelector(".date-format"); const timestamp = `2026-08-22T05:32:16`; const parsedDate = new Date(timestamp); if (!isNaN(parsedDate)) { const contextualTime = getContextualTime(parsedDate); const humanReadableDate = formatHumanReadableDate(parsedDate); dateElement.innerText = contextualTime; dateElement.style.cursor = "pointer"; // Set the human-readable date as a tooltip dateElement.setAttribute("title", humanReadableDate); } else { console.error( `Invalid date format for element with class 'date-format'` ); }