今日の日付は、JavaScriptで以下の通りに書きます。
const today = new Date();
const todayHtml = today.getFullYear() + '/' + (today.getMonth() + 1) + '/' + today.getDate();
document.write('<p class="date">' + todayHtml + '</p>');
HTMLとJavaScript全体のコードは以下の通りです。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>TODAY</title>
<!--Bootstrap CDN ここから-->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
<!--Bootstrap CDN ここまで-->
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>TODAY</h1>
</header>
<div class="container">
<script>
const today = new Date();
const todayHtml = today.getFullYear() + '/' + (today.getMonth() + 1) + '/' + today.getDate();
document.write('<p class="date">' + todayHtml + '</p>');
</script>
</body>
</html>
【プログラマー未経験者の方へ】
ドットインストールが難しくて萎えている方や、模写コーディングが出来なくて悩んでいる方はUdemyがめっちゃおすすめです。
僕はプログラマー未経験者ですが、以下の記事の講座で模写コーディング、さらには自分でコーディングできるまでになりました。
https://greenberet.net/mosya-coding-udemy/
僕はコーディングできるまでかなり苦しみ、何度も挫折しかけましたが、Udemyに助けられました。
参考にしていただければ幸いです。