Skip to content

Commit 2374858

Browse files
committed
init commit
1 parent aa9f32a commit 2374858

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
<input type="date" />
10+
11+
<script src="script.js"></script>
12+
</body>
13+
</html>

script.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
document.addEventListener("DOMContentLoaded", (event) => {
2+
const dateInput = document.querySelector("input");
3+
const today = new Date();
4+
const year = today.getFullYear();
5+
const month = String(today.getMonth() + 1).padStart(2, "0"); // Months are zero-based
6+
const day = String(today.getDate()).padStart(2, "0");
7+
const formattedDate = `${year}-${month}-${day}`;
8+
dateInput.value = formattedDate;
9+
});

0 commit comments

Comments
 (0)