<header>
<h2 class="title">Date.prototype.toDateString()</h2>
<p class="description">Перетворює об'єкт Date в зрозумілий рядок, який представляє тільки дату.</p>
</header>
<main>
<div class="result">
<button id="generateDate">Згенерувати Дату</button>
<p id="dateString">Тут буде рядок дати...</p>
</div>
</main>
body {
font-size: 16px;
line-height: 1.5;
font-family: monospace;
}
header {
background-color: #f1f1f1;
margin-bottom: 25px;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
header h2.title {
padding-bottom: 15px;
border-bottom: 1px solid #999;
}
header p.description {
font-style: italic;
color: #222;
}
.result {
background-color: #f8f8f8;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
button {
cursor: pointer;
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
}
button:hover {
background-color: white;
color: black;
border: 1px solid #4CAF50;
}
document.getElementById('generateDate').addEventListener('click', function() {
const currentDate = new Date();
document.getElementById('dateString').textContent = currentDate.toDateString();
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.