0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

js問題date

Posted at
date
<!DOCTYPE html>
<html>
<head>
    <title>Js問題 CalcDate</title>
</head>
<body>
    <input type="text" id="dateInput" placeholder="yyyy/MM/dd">
    <br>
    <button onclick="CalcDate()">計算</button>
    <br>
    <input type="text" id="result">
    
    <script>
        function CalcDate() {
            
            //入力された日付の処理
            let inputStr = document.getElementById("dateInput").value;
            let inputDate = new Date(inputStr);
            let num1 = inputDate.getFullYear() + inputDate.getMonth() + 1 + inputDate.getDate();
            console.log(num1);
            //本日日付の処理
            let today = new Date();
            let num2 = today.getFullYear() + today.getMonth() + 1 + today.getDate();
            console.log(num2);
            // 結果を表示
            document.getElementById("result").value = num1 - num2;
        }
    </script>
</body>
</html>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?