Created
May 3, 2021 08:26
-
-
Save Tynael/81919841e5b6eceb30c411df4d9f26af to your computer and use it in GitHub Desktop.
JavaScript Code Example
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> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example used for: https://neutrondev.com/5-popular-programming-languages-and-their-uses/