Skip to content

Instantly share code, notes, and snippets.

@Tynael
Created February 19, 2017 20:36
Show Gist options
  • Save Tynael/b3f09236814727a54d9f77179525b723 to your computer and use it in GitHub Desktop.
Save Tynael/b3f09236814727a54d9f77179525b723 to your computer and use it in GitHub Desktop.
Show Current Date
<!DOCTYPE html>
<title>My Example</title>
<time id="date"></time>
<script>
/*
Create a JavaScript Date object for the current date and time,
then extract the desired parts, then join them again in the desired format.
*/
var currentDate = new Date(),
day = currentDate.getDate(),
month = currentDate.getMonth() + 1,
year = currentDate.getFullYear(),
date = day + "/" + month + "/" + year;
// Output the date to the above HTML element
document.getElementById("date").innerHTML = date;
</script>
// http://www.quackit.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment