Skip to content

Instantly share code, notes, and snippets.

@davidvandenbor
Last active March 15, 2022 21:49
Show Gist options
  • Save davidvandenbor/32873f38391483ff35fd6cf053d6a0cc to your computer and use it in GitHub Desktop.
Save davidvandenbor/32873f38391483ff35fd6cf053d6a0cc to your computer and use it in GitHub Desktop.
Get the full date from the Javascript Date() method.
<!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