Created
April 24, 2020 17:54
Revisions
-
RashidJorvee created this gist
Apr 24, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <html> <body> <h2>Current date using JavaScript new Date()</h2> <p id="demo"></p> <p id="demo1"></p> <p id="demo2"></p> <p id="demo3"></p> <script> //Create object of Date var today = new Date(); //using getDate function get the date from Date object document.getElementById("demo1").innerHTML = day = today.getDate().toString().padStart(2, "0"); //using getMonth function get the month from Date object document.getElementById("demo2").innerHTML = month = (today.getMonth() + 1).toString().padStart(2, "0") //using getYear function get the year from Date object document.getElementById("demo3").innerHTML = year = today.getFullYear(); //Now concatinate all those variables in create a format whatsoever you want. document.getElementById("demo").innerHTML = year.toString() + month.toString() + day.toString(); </script> </body> </html>