Created
July 24, 2023 21:11
-
-
Save Davisonpro/8405921e14ed045292277500b4e5178a to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Display Current Date and Time</title> | |
</head> | |
<body> | |
<span id="datetime-display"></span> | |
<script> | |
// Function to display current date and time | |
const datetimeDisplayElement = document.getElementById("datetime-display"); | |
// Create a new Date object | |
const currentDateTime = new Date(); | |
// Extract the date and time components | |
const date = currentDateTime.toDateString(); | |
const time = currentDateTime.toLocaleTimeString(); | |
// Display the date and time in the span element | |
datetimeDisplayElement.textContent = `Current Date: ${date} | Current Time: ${time}`; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment