Skip to content

Instantly share code, notes, and snippets.

@anwerashif
Created February 18, 2025 04:55
Show Gist options
  • Save anwerashif/bfa07199b19ff0a072a6bc057b7a258f to your computer and use it in GitHub Desktop.
Save anwerashif/bfa07199b19ff0a072a6bc057b7a258f to your computer and use it in GitHub Desktop.
Code to Add Current Date
<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