How to display todays date with JavaScript
- Web Coding

 - Oct 29, 2020
 - 1 min read
 
Today I will be teaching you how to display todays date using only HTML, CSS and JavaScript.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <link rel="stylesheet" href="style.css">
</head>
<body>
 <p>Todays date is: <span id="date"></span></p>
 
 <script src="script.js"></script>
</body>
</html>CSS
*{
 padding: 0;
 margin: 0;
}
body{
 min-height: 100vh;
 display: flex;
 align-items: center;
 justify-content: center;
 background-color: #272727;
}
p{
 font-size: 48px;
 color: #86C232;
}JavaScript
dateDisplay = document.getElementById('date');
let date = new Date();
dateDisplay.innerHTML = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on
YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ
Instagram: https://www.instagram.com/coding_for_the_web/
Twitter: https://twitter.com/LearnWebCoding



Comments