Created
February 18, 2025 04:55
-
-
Save anwerashif/bfa07199b19ff0a072a6bc057b7a258f to your computer and use it in GitHub Desktop.
Code to Add Current Date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
document.addEventListener("DOMContentLoaded", function () { | |
// Select the element | |
const dateElement = document.querySelector(".myDate u"); | |
if (dateElement) { | |
// Format the current date as "Month DD, YYYY" | |
const options = { year: "numeric", month: "long", day: "2-digit" }; | |
const currentDate = new Date().toLocaleDateString("en-US", options); | |
// Update the text content | |
dateElement.textContent = currentDate; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment