Last active
March 15, 2022 21:49
-
-
Save davidvandenbor/32873f38391483ff35fd6cf053d6a0cc to your computer and use it in GitHub Desktop.
Get the full date from the Javascript Date() method.
This file contains 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> | |
<body> | |
<p id="demo"></p> | |
<script> | |
// Create arrays for the months and the weekdays | |
const weekdays = ["Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag","Zondag"]; | |
const months = ["January","February","Maart","April","Mei","Juni","July","August","September","October", "November","December"]; | |
datum = new Date(); | |
let week = weekdays[datum.getDay()]; | |
let day = datum.getDate(); | |
let month = months[datum.getMonth()]; | |
let year = datum.getFullYear(); | |
// add the returned date to an HTML object | |
document.getElementById("demo").innerHTML = `${week} ${day} ${month} ${year}`; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment